aUCBLogo Demos and Tests / morph
be morph
cs ht
setUpdateGraph false
::howmany=120
s = 300
::positions=[]
f=flatline s f2=flatline2 s fls=flatlines s
sq=square s tri=triangle s c=circ s star5=star s
sm=smiley s sd=sadie s ea=earnest s
foreach [f f2 fls sq tri c star5 sm sd ea]
[ make ? interpolated thing ?
]
cs setScreenColor 0
x=sq+0 ; be create the same structure as in x, so that we can use xcopy and x+=v
ox=x+0
col=array count x
repeat count x
[ col.repcount=hsb 360*repcount/count x 1 1
]
steps=int mips/20
new=sq
v = (new-x)/steps
imax=random steps
i=0
t=0
forever
[; t0=timefine
if key? [stop]
xcopy "ox x ; copy only the values (no new nodes are made)
x+=v ; dito
v*=0.9
v+=(new-x)/steps
clean
line x col
updateGraph
i=i+1
if i > imax
[ i=0
imax=steps*3/2+random steps
new=thing pick
[ fls f f2
sq tri c star5
sm sm sd ea
]
v+=(new-x)/steps
]
gc
; t = (i*t + timefine-t0)/(i+1)
; ct (pr 1/t "frames/sec)
]
end
be interpolated list_
output resize array :list_ howmany
end
be record position
queue "positions :position
end
be fb s
fd2 s bk s
end
be fd2 s
fd s
record pos
end
be flatline s
positions=[]
repeat 2 [fb s rt 180]
output :positions
end
be flatline2 s
positions=[]
repeat 2
[ positions=sentence positions flatline s
rt 180
]
output :positions
end
be flatlines s
positions=[]
repeat 2
[ bk s/2 rt 90
positions=sentence positions flatline s
lt 90 fd s/2
rt 180
]
output :positions
end
be square s
local [r]
positions=[]
r=s/sqrt 2
repeat 4 [fb r rt 90]
fb r
output :positions
end
be triangle s
local [r]
positions=[]
r=s/sqrt 3
repeat 3 [fb r rt 120]
fb r
output :positions
end
be circ d
local [r n]
positions=[]
r=d/sqrt pi
n=30
repeat n [fb r rt 360/n]
fb r
output :positions
end
be star s
local [r n]
positions=[]
r=s/exp 1 ; s/sqrt pi
n=5
repeat n
[ fb r rt 180/n
fb s rt 180/n
]
fb r
output :positions
end
be earnest s
local [n]
eyes_n_nose s
bk s/4 rt 90
positions=sentence positions flatline s/6
lt 90 fd s/4
output :positions
end
be eyes_n_nose s
positions=[]
positions=circ s
rt 45 smile_eye s
lt 90 smile_eye s
rt 45 positions=sentence positions triangle s/10
end
be sadie s
local [n]
eyes_n_nose s
rt 180 fd s/2 smile s rt 180 fd s/2
output :positions
end
be smile s
rt 120
n=10
repeat n [fb s/4 rt 120/n]
rt 120
end
be smile_eye s
fd s/4 positions=sentence positions circ s/8 bk s/4
end
be smiley s
local [n]
eyes_n_nose s
smile s
output :positions
end