aUCBLogo Demos and Tests / sierp
to sierp
; This program creates three equivalent forms using various looping structures
cs ht
pu setxy -250 -100 seth 11 pd
make "t timemilli
image_left
pr timemilli-:t
pu setxy 120 -100 seth 11 pd setpc 0
make "t timemilli
image_right 0
pr timemilli-:t
pu home st
end
to image_left
; nested repeat
repeat 3 ~
[ setpc 9 fd 128
repeat 3 ~
[ setpc 10 fd 64
repeat 3 ~
[ setpc 11 fd 32
repeat 3 ~
[ setpc 12 fd 16
repeat 3 ~
[ setpc 13 fd 8
repeat 3 ~
[ setpc 14 fd 4
repeat 3 ~
[ setpc 15 fd 2
repeat 3 ~
[ setpc 16 fd 1
rt 120
]
rt 120
]
rt 120
]
rt 120
]
rt 120
]
rt 120
]
rt 120
]
rt 120
]
end
to triangle
lt :tilt
repeat 3 ~
[ setpc 17-:level
fd :size
fractal :size/2 :level-1
rt 120
]
rt :tilt
end
to fractal :size :level
if :level < 1 [stop]
triangle
end
to image_right :tilt
; recursive
rt :tilt
fractal 128 8
end