aUCBLogo Demos and Tests / leaves
to leaves
perspective
WindowMode
setLightAmbient "light grey
cs
hideTurtle
maplebitmap=loadImage "maple.jpg
BitMakeTransparent maplebitmap BitPixel maplebitmap 1 1
mapletex=Texture maplebitmap
leafCount=10
leafGraphic=Array leafCount
repeat leafCount
[ leafGraphic.repcount=drawLeaf 300*sqrt rnd+0.5
]
cs
N=20
turtl=Array N
repeat N
[ i=repcount
turtl.i=newTurtle
setTurtle turtl.i
ht
setUpdateGraph false
down 90 rt random 360
a=random 50 up a fd 300+random 100 down a
rt 90
]
rol=(random int rseq 360 360 N)+0.1
drol=(random int rseq 2 2 N)-2
running=true
index=(random int rseq leafCount leafCount N)+1
while [running]
[ clean
Texture mapletex
repeat N
[ i=repcount
setTurtle turtl.i
fd 10
right 2
rr rol.i
leaf index.i
lr rol.i
rol.i=rol.i+drol.i
]
updateGraph
if keyP [running=false]
]
end
to drawLeaf s
halfMapleLeaf=
[ l 115.5
f .05
r 30
f .05
l 10
f .1
r 30
f .2
l 20
f .1
r 120
f .1
l 50
f .2
l 30
f .1
r 140
f .07
l 120
f .1
r 30
f .1
l 30
f .07
r 40
f .05
r 160
f .05
l 40
f .1
l 40
f .2
r 20
f .1
l 120
f .2
r 20
f .1
r 150
f .05
l 110
f .1
l 40
f .06
r 30
f .05
l 30
f .05
r 75.5
]
MapleLeaf=se halfMapleLeaf reverse2 halfMapleLeaf
entex
setpc hsb random 120 0.7 1
setTessWindingRule 3
GraphicStart
;comment
;[
TessStart
run MapleLeaf
repeat 2
[ f .3
r 90
f .01
r 90
]
TessEnd
lt 180
;] setfc "white
; fillRect [0 0][100 100]
output GraphicEnd
end
to f d
pu fd s*d
setTexPos Pos/s*0.8+[0.5 0.15]
back s*d
pd
fd s*d
end
to l a
left a
end
to r a
right a
end
to reverse2 in
out=[]
while [not empty? in]
[ out=se (se first in first bf in) out
in=bf bf in
]
output out
end
to leaf n
drawGraphic leafGraphic.n
end