use canvas, math, std msg = "" NUM_POINTS = 0 while (NUM_POINTS <= 2 || NUM_POINTS > 25) { NUM_POINTS = 0 + prompt("Сколькиугольник? (3..25)" + msg) if (NUM_POINTS <= 2) msg = "!! Сказано же, ну!" else if (NUM_POINTS > 25) msg = " Чувак, " + NUM_POINTS + " это будет ООООЧЕНЬ долго!" } angle = 2*PI / NUM_POINTS; DIVIDER = 2.8 w = 800 h = 600 window("Fractal polygon demo", w, h) fractal(w/2, h/2, w/2) repaint() def cpoly(cx, cy, size) { ox = cx oy = cy - size ang = 0 for i = 0, i < NUM_POINTS, i++ { ang += angle nx = cx - sin(ang)*size ny = cy - cos(ang)*size line(ox, oy, nx, ny) ox = nx oy = ny } } def fractal(cx, cy, size) { if size >= 3 { s2 = size / 2 sD = size / DIVIDER color(0, 0, 255 - size * 255 / w/2) cpoly(cx, cy, sD) fractal(cx, cy - s2, sD) for n = 0, n < NUM_POINTS, n++ { fractal(cx - sin(angle*n)*s2, cy - cos(angle*n)*s2, sD) } } }