aUCBLogo Demos and Tests / chartest
be chartest
ifelse Name? "framenr
[ singleshot=true
][ singleshot=false
]
ifElse (not singleshot) or2 not name? "dÏ
[ setUpdateGraph false
perspective
eye=Array 3
eye.2=200
center={0 0 0}
upvector={0 1 0}
Ï=0
dÏ=0.3
bÏ=90
cS hT
setPenColor "white
setPenSize [1 1]
down 90 fd 100 rt 90
o=Orientation
bmpiris=loadImage "iris.png
texIris=Texture bmpiris
pr [press + or - to change the flying speed]
][ Ï=10*framenr
]
forever
[ clean
Texture texIris
eye.1=500*Sin Ï
eye.3=500*Cos Ï
setEye eye center upvector
uP 20*Cos 1*Ï
butterfly 100 bÏ
setOrientation o
updateGraph
Ï=Ï+dÏ
bÏ=70*Sqr Cos 5*Ï
if singleshot [break]
if Key?
[ c=readChar
if c==Char 27 [stop]
if c=="+ [dÏ=dÏ+0.2]
if c=="- [dÏ=dÏ-0.2]
if c==Char 255
[ c=readCharExt
if c==wxk_numpad_add [dÏ=dÏ+0.2]
if c==wxk_numpad_subtract [dÏ=dÏ-0.2]
]
]
]
end
be butterfly size bÏ
local [o]
pos0=PosXYZ
o=Orientation
fdist=1
Ï=0
x=0
y=0
sÏ=1
home
if not name? "grRightWing
[ grRightWing=Graphic [rightwing size]
]
sÏ=-1
home
if not name? "grLeftWing
[ grLeftWing=Graphic [leftwing size]
]
setPosXYZ pos0
setOrientation o
body size
butterfly_reset
rightantenna size
butterfly_reset
leftantenna size
butterfly_reset
fd2 size/2
leftRoll bÏ
drawGraphic grRightWing
butterfly_reset
fd2 size/2
rightRoll bÏ
drawGraphic grLeftWing
butterfly_reset
be body size
PD Ellipsoid size/8 size size/8
end
be butterfly_reset
PU setPosXYZ pos0 setOrientation o
end
be rightwing size
PenDown
Tesselation
[ fdist=1
Ï=0
x=0.2
y=0.2
repeat 22 [fd2 size/100 rt2 2]
fd2 size*1.6
repeat 67 [fd2 size/100 rt2 2]
fd2 size*1.2
repeat 43 [fd2 size/100 rt2 2]
fd2 size*1.4
fdist=0.6
Ï=0
x=0
y=0
lt2 165 fd2 size/1.2
repeat 60 [fd2 size/100 rt2 1.5]
fd2 size/8
repeat 70 [fd2 size/100 rt2 1.5]
fd2 size/1.4
]
end
be leftwing size
PenDown
Tesselation
[ fdist=1
Ï=0
x=0.2
y=0.2
repeat 22 [fd2 size/100 lt2 2]
fd2 size*1.6
repeat 67 [fd2 size/100 lt2 2]
fd2 size*1.2
repeat 43 [fd2 size/100 lt2 2]
fd2 size*1.4
fdist=0.6
Ï=0
x=0
y=0
rt2 165 fd2 size/1.2
repeat 60 [fd2 size/100 lt2 1.5]
fd2 size/8
repeat 70 [fd2 size/100 lt2 1.5]
fd2 size/1.4
]
end
be rightantenna size
fd size
rt 90 fd 2 lt 90
make "ANG 1
repeat 16 [PD fd size/25 rt ANG make "ANG ANG+1]
end
be leftantenna size
fd size
lt 90 fd 2 rt 90
make "ANG 1
repeat 16 [PD fd size/25 lt ANG make "ANG ANG+1]
end
be fd2 dist
x=x+dist/fdist/250*sin Ï*sÏ
y=y+dist/fdist/250*cos Ï*sÏ
setTexXY x y
forward dist
end
be rt2 ang
Ï=Ï+ang
right ang
end
be lt2 ang
Ï=Ï-ang
left ang
end
end