aUCBLogo Demos and Tests / mappingcyl
;Hi!
;here is another demo for aUCBLogo in a file map1.lg
;Hope you will enjoy it.
;Best regards.
;mhelhefny
to cyl :r :v
pu for [u 0 360 20][for [v -:v :v 40][cylpos :r :u :v pd]pu]
pu for [v -:v :v 40][for [u 0 360 20][cylpos :r :u :v pd]pu]
end
to cylpos r fi y
setxyz r*cos fi y r*sin fi
end
to fl :size
pu
for [s 0 :size]
[ cylpos :r :u+:s*cos heading :v+:s*1.5*sin heading
pd
]
make "u :u+:size*cos heading
make "v :v+:size*1.5* sin heading
end
to mappingCyl
perspective
cs ht
setlabelsize [20 40]
setLabelAlign 0 0
setupdategraph false
s=[ [square spiral]
[circular spiral]
[penta spiral]
[dragon]
[hilbert curve]
[see]
[penta star]
[snow flake]
[sierpinski carpet]
[star1]
[tree]
[sierpinski triangle]
[penta]
]
pr [ESC stops, + - chooses demo, * / changes speed]
demos=[ [hil1]
[hil2]
[hil3]
[hil4]
[hil5]
[hil6]
[hil7]
[hil8]
[hil9]
[hil10]
[hil11]
[hil12]
[hil13]
]
phi=0 dphi=2 ddphi=dphi/4
i=1 r=70 v=150
eye={-400 -400 -400}
run demos.i
forever
[ phi=phi+dphi
eye.1= -400*sin phi
eye.3= -400*cos phi
setEye eye {0 0 0}{0 1 0}
redraw
if key?
[ c=rc
if c==char 27 [stop]
if c=="+ [if i < 13 [i=i+1] run demos.i]
if c=="- [if i > 1 [i=i-1] run demos.i]
if c=="* [dphi=dphi+ddphi]
if c=="/ [dphi=dphi-ddphi]
]
gc
]
end
to hil1
make "u 10 make "v 30 setpc 2 j s.1 sq2 2 setpc 11
cyl :r 150
end
to hil10
make "u 25 make "v -30 setpensize [0 0] setpc 2
j s.10 star1 50 5 setpensize [0 0] setpc 11 cyl :r 150
end
to hil11
make "u 70 make "v -90 setpensize [0 0] setpc 2
j s.11 rt 90 tree 5 50 setpensize [0 0] setpc 11 cyl :r 150
end
to hil12
make "u 0 v= -100
setpc 2 j s.12 star2 360 3 setpc 11 cyl :r 150
end
to hil13
make "u 0 v= -80
setpc 2 j s.13 star2 160 5 setpc 11 cyl :r 150
end
to hil2
make "u 60 make "v -20 setpc 2 rt 90 j s.2
sq 0.5 setpc 11 cyl :r 150
end
to hil3
make "u 30 make "v 10 setpc 2 j s.3
sq1 2 setpc 11 cyl :r 150
end
to hil4
make "u 20 make "v -20 setpc 2 j s.4
rdragon 3 10 setpc 11 cyl :r 150
end
to hil5
make "u 30 make "v 110 j s.5
setpc 2 hilbert 10 4 1 setpc 11 cyl :r 150
end
to hil6
make "u -30 make "v 20 j s.6
setpc 2 lt 45 see 260 setpc 11 cyl :r 150
end
to hil7
make "u 0 v= -120
setpc 2 j s.7 star 90 5 setpc 11 cyl :r 150
end
to hil8
u=30 v=-10 setpc 2 setpensize [0 0]
j s.8 snow 280 setpc 11 setpensize [0 0] cyl :r 150 waitms 5
end
to hil9
make "u 30 make "v -80 setpensize [0 0] setpc 2
j s.9 star2 360 4 setpensize [0 0] setpc 11 cyl :r 150
end
TO HILBERT :SIZE :LEVEL :PARITY
IF :LEVEL == 0 [STOP]
LEFT :PARITY * 90
LOCAL "L
MAKE "L :LEVEL - 1
HILBERT :SIZE :L (-:PARITY)
Fl :SIZE
RIGHT :PARITY * 90
HILBERT :SIZE :L :PARITY
Fl :SIZE
HILBERT :SIZE :L :PARITY
RIGHT :PARITY * 90
Fl :SIZE
HILBERT :SIZE :L (-:PARITY)
LEFT :PARITY * 90
end
to j :s
cs pu setxyz 0 225 0 seth 90 label [mapping on a cylinder ]
setxyz 0 -230 0 seth 90 label :s home
end
to ldragon :l :lev
if :lev==0 [fl :l stop]
ldragon :l :lev-1 rt 90
rdragon :l lev-1
end
to rdragon :l :lev
if :lev==0 [fl :l stop]
ldragon :l :lev-1 lt 90
rdragon :l lev-1
end
to see :l
if :l<3 [fl :l stop]
see :l*0.6 lt 90
see :l*0.6 rt 90
end
to snow :size
if :size < 3 [fl :size stop]
snow :size/3 rt 60
snow :size/3 lt 120
snow :size/3 rt 60
snow :size/3
end
to sq :size
if :size>17[stop]
fl :size rt 10
sq :size+0.1
end
to sq1 :size
if :size>70[stop]
fl :size rt 73
sq1 :size+1
end
to sq2 :size
if :size>90[stop]
fl :size rt 90
sq2 :size+2
end
to star :l :n
if :l<3 [fl :l stop]
repeat :n[fl :l/3 star :l/3 :n fl :l*2/3 rt 360/:n]
end
to star1 :l :n
pu fl :l*2
if :l>2 [repeat :n[star1 :l/3 :n fl :l/3 rt 360/:n pd]]
pu fl -:l*3
end
to star2 :l :n
if :l>20 [repeat :n[star2 :l*0.47 :n fl :l/3 rt 360/:n pd]]
end
to tree level size
if level==0 [stop]
fl size
lt 80
tree2 level-1 size/2
rt 70
tree level-1 size*2/3
rt 90
tree2 level-1 size/2
lt 80
fl -size
end
to tree2 level size
if level==0 [stop]
fl size
rt 80
tree level-1 size/2
lt 70
tree2 level-1 size*2/3
lt 90
tree level-1 size/2
rt 40
tree level-1 size*4/5
rt 40
fl -size
end