aUCBLogo Demos and Tests / candle
be candle
refresh
setUpdateGraph false
cs
ht
setsc [0 0 0]
perspective
setEye {0 400 600}{0 0 0}{0 1 0}
size=300
thickness=50
red=RGB 1 0 0
black=0
white=RGBA 1 1 1 .1
lightblack=RGBA 0 0 0 .06
drawCandle
GraphicStart
setMaterialEmission 0
back size*2/5
down 90
setFloodColor red
fillCircle thickness
up 90
setPenColor lightblack ;wick
setPenSize [10 10]
PenDown
fd size*2/5
candlegr=GraphicEnd
bm=BitCopy 2 2
wax=[]
waxr=[]
waxdy=0.2
counter=0
countermax=30+random 300
counter2=0
norefresh
running=true
OnChar [running=false OnChar[]]
while [running]
[
tex=Texture bm
setDepthFunc 7
entex
setPenColor white
setMaterialEmission white
FillRect [-99 -98][116 177]
distex
setFloodColor lightblack
setMaterialEmission lightblack
FillRect [-99 -98][116 177]
setFloodColor red
setMaterialEmission white
setDepthFunc 7
setPenColor HSBA random 40 1 1 .30
setMaterialEmission PenColor
Ellipsoid 10+random 5 50+random 20 10+random 5
PenUp
p=PosXYZ
back 100
left 90 fd 100 right 90
bm=BitCopy 200 260
setPosXYZ p
setDepthFunc 7
drawGraphic candlegr
setDepthFunc 3
drawGraphic candlegr
moveWax
updateGraph
deleteTextures
GC
dispatchMessages
]
pr [;OK]
be drawCandle
setPenSize (list thickness*2 thickness*2) ;candle
setPenColor red
setMaterialEmission 0
PenUp
back size+size*2/5
PenDown
enableCylinderLines
disableRoundLineEnds
fd size
PenUp
fd size*2/5
end
be moveWax
counter=counter+1
if counter >= countermax
[ counter=0
counter2=counter2+1
if counter2 >= 20
[ wax=[]
waxr=[]
counter=0
clearScreen
drawCandle
]
countermax=30+random 300
phi=random 180
r=3+random 5
push "wax (list
thickness*cos phi -size*2/5-r thickness*sin phi)
push "waxr r
]
p=PosXYZ
setPenColor red
(foreach wax waxr
[ setPosXYZ ?1
Ellipsoid ?2+random ?2 2*?2 ?2+random ?2
setItem # wax (list
first ?1 (first bf ?1)-waxdy first bf bf ?1)
])
newwax=[]
newwaxr=[]
(foreach wax waxr
[ if (?1).2 > -(size+size*2/5)
[ push "newwax ?1
push "newwaxr ?2
]
])
wax=newwax
waxr=newwaxr
setPosXYZ p
end
end