Листинг программы:
Демонстрация работы:
Код: Выделить всё
open window 640,512
backcolor 0,0,0
clear window
for sides=3 to 10
clear window
scale=(sides-2)/(sides-1)
dim p(sides,2)
for x=0 to sides
angle=(x/sides)*2*3.141
p(x,1)=320+256*cos(angle)
p(x,2)=256+256*sin(angle)
next x
px=ran(640)
py=ran(512)
c=0
repeat
color ran(256),ran(256),ran(256)
point=max(min(sides,ran(sides)+1),1)
px=((p(point,1)-px)*scale)+px
py=((p(point,2)-py)*scale)+py
fill rectangle px,py to px+1,py+1
c=c+1
until (c>10000)
pause 2
next sides