compressed
set display mode 1024,768,32:sync on:sync rate 60:#CONSTANT POINTS 1000:#CONSTANT MIDDLEMIN 98:#CONSTANT MIDDLEMAX 100:#CONSTANT NBMIN 10:#CONSTANT NBMAX 10:tl as float
type Tpoint x#,y#,nb,dist endtype:dim p(POINTS) as Tpoint:tl=360.0/POINTS:for t=0 to POINTS:p(t).nb=t+1:p(t).dist=300:next t:p(POINTS).nb=0:do:cls rgb(255,255,255):x=mousex():y=mousey():For t=0 to POINTS:line p(t).x#,p(t).y#,p(p(t).nb).x#,p(p(t).nb).y#:dist=sqrt((p(t).x#-x)^2+(p(t).y#-y)^2):angle=atan_full(x-p(t).x#,y-p(t).y#):if dist<MIDDLEMIN:p(t).x# = x+cos(angle)*(dist+(MIDDLEMIN-dist)*.98):p(t).y#=y+sin(angle)*(dist+(MIDDLEMIN-dist)*.98):endif
if dist>MIDDLEMAX:p(t).x#=x+cos(angle)*(dist+(MIDDLEMAX-dist)*.98):p(t).y#=y+sin(angle)*(dist+(MIDDLEMAX-dist)*.98):endif:ink rgb((MIDDLEMAX-dist)/2,0,128-(MIDDLEMAX+dist)/2),0:x2=p(p(t).nb).x#:y2=p(p(t).nb).y#:dist=sqrt((p(t).x#-x2)^2+(p(t).y#-y2)^2):angle=atan_full(x2-p(t).x#,y2-p(t).y#)
if dist<NBMIN:p(t).x#=x2+cos(angle)*(dist+(NBMIN-dist)*.98):p(t).y#=y2+sin(angle)*(dist+(NBMIN-dist)*.98):endif:if dist>NBMAX:p(t).x#=x2+cos(angle)*(dist+(NBMAX-dist)*.98):p(t).y#=y2+sin(angle)*(dist+(NBMAX-dist)*.98):endif:next t:sync:loop
function atan_full(dist_x as float, dist_y as float):if dist_y => 0:if dist_x>0:exitfunction 180.0+abs(Atan(dist_y/dist_x)):endif:if dist_x<0:exitfunction 360.0-abs(Atan(dist_y/dist_x)):endif:if dist_x=0:exitfunction 270.0:endif:else:if dist_x>0:exitfunction Atan(dist_y/dist_x)+180.0:endif:if dist_x<0:exitfunction Atan(dist_y/dist_x):endif:if dist_x=0:exitfunction 90.0:endif:endif
endfunction 0.0
uncompressed
set display mode 1024,768,32
sync on : sync rate 60
#CONSTANT POINTS 1000
#CONSTANT MIDDLEMIN 98
#CONSTANT MIDDLEMAX 100
#CONSTANT NBMIN 10
#CONSTANT NBMAX 10
x as integer : y as integer
tl as float
type Tpoint
x as float
y as float
nb as integer
dist as integer
endtype
dim p(POINTS) as Tpoint
position mouse 512,384
x = mousex() : y = mousey()
tl = 360.0/POINTS
For t = 0 to POINTS
p(t).x = x+cos(t*tl)*300
p(t).y = y+sin(t*tl)*300
p(t).nb = t+1
p(t).dist = 300
next t
p(POINTS).nb = 0
do
cls rgb(255,255,255)
x = mousex() : y = mousey()
For t = 0 to POINTS
line p(t).x,p(t).y,p(p(t).nb).x,p(p(t).nb).y
dist = sqrt((p(t).x-x)^2+(p(t).y-y)^2)
angle = atan_full(x-p(t).x,y-p(t).y)
if dist < MIDDLEMIN
p(t).x = x+cos(angle)*(dist+(MIDDLEMIN-dist)*.98)
p(t).y = y+sin(angle)*(dist+(MIDDLEMIN-dist)*.98)
endif
if dist > MIDDLEMAX
p(t).x = x+cos(angle)*(dist+(MIDDLEMAX-dist)*.98)
p(t).y = y+sin(angle)*(dist+(MIDDLEMAX-dist)*.98)
endif
ink rgb((MIDDLEMAX-dist)/2,0,128-(MIDDLEMAX+dist)/2),0
x2 = p(p(t).nb).x
y2 = p(p(t).nb).y
dist = sqrt((p(t).x-x2)^2+(p(t).y-y2)^2)
angle = atan_full(x2-p(t).x,y2-p(t).y)
if dist < NBMIN
p(t).x = x2+cos(angle)*(dist+(NBMIN-dist)*.98)
p(t).y = y2+sin(angle)*(dist+(NBMIN-dist)*.98)
endif
if dist > NBMAX
p(t).x = x2+cos(angle)*(dist+(NBMAX-dist)*.98)
p(t).y = y2+sin(angle)*(dist+(NBMAX-dist)*.98)
endif
next t
if mouseclick()
For t = 0 to POINTS
l = 50+rnd(200)
p(t).x = x+cos(t*tl)*l
p(t).y = y+sin(t*tl)*l
next t
endif
sync : loop
function atan_full(dist_x as float, dist_y as float)
if dist_y => 0
if dist_x > 0 then exitfunction 180.0 + abs(Atan(dist_y/dist_x))
if dist_x < 0 then exitfunction 360.0 - abs(Atan(dist_y/dist_x))
if dist_x = 0 then exitfunction 270.0
else
if dist_x > 0 then exitfunction Atan(dist_y/dist_x) + 180.0
if dist_x < 0 then exitfunction Atan(dist_y/dist_x)
if dist_x = 0 then exitfunction 90.0
endif
endfunction 0.0