aUCBLogo Demos and Tests / uncurl
to uncurl
cs
ht
setScreenColor 0
setUpdateGraph false
n=100
x=Array n
ox=Array n
v=Array n
c=Array n
repeat n
[ x.repcount=List (random 400)-200.01 (random 400)-200.01
v.repcount=List (random 400)/100-2.01 (random 400)/100-2.01
c.repcount=hsb 360*repcount/n 1 1
]
ox=x+0 ; to create the same structure as in x, so that we can use xcopy and x+=v
i=0
t=0
forever
[; t0=timefine
if key? [stop]
xcopy "ox x ; copy only the values (no new nodes are made)
x=x+v
x=(x*6+(rotate x 1)+(rotate x -1))/8
f=1400/norm norm x
x=x*f
v=v*f
repeat n
[ if (maxnorm x.repcount) > 201
[ ifelse (abs first x.repcount) > 201
[ _setFirst v.repcount -first v.repcount
]
[ _setFirst bf v.repcount -last v.repcount
]
]
]
clean
line x c
line (list last x first x)(list last c first c)
updateGraph
gc
; t = (i*t + timefine-t0)/(i+1)
; ct (pr 1/t "frames/sec)
; i+=1
]
end