Compare commits
No commits in common. "88d9e3b2e3979ef317815b8c6cd702abbded2bb9" and "6c8c667042b4610a2556a42370603afabb8f8c37" have entirely different histories.
88d9e3b2e3
...
6c8c667042
|
@ -3,18 +3,18 @@
|
|||
box states = []
|
||||
|
||||
fn push! () -> {
|
||||
update! (states, append (_, unbox (turtle_state)))
|
||||
update! (states, append (_, turtle_state ()))
|
||||
}
|
||||
|
||||
fn pop! () -> {
|
||||
let state = do states > unbox > last
|
||||
update! (states, butlast)
|
||||
penup! ()
|
||||
loadstate! (state)
|
||||
load_turtle_state! (state)
|
||||
}
|
||||
|
||||
fn branch! () -> {
|
||||
pc! (colors :green)
|
||||
pc! (colors :olive)
|
||||
pw! (4)
|
||||
fd! (20)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,25 @@ fn randcolor () -> (random (0, 255), random (0, 255), random (0, 255))
|
|||
|
||||
fn pen_randcolor! () -> pencolor! (randcolor ())
|
||||
|
||||
fn spiral_gon! (iter) -> {
|
||||
loop (30, 0, colors :lime) with (size, times, color) -> {
|
||||
let randcolor = (random(0, 255), random(0, 255), random (0, 255))
|
||||
let newcolor = if eq? (color, colors :lime)
|
||||
then colors :fuchsia
|
||||
else colors :lime
|
||||
if lt? (times, iter)
|
||||
then {
|
||||
pen_randcolor! ()
|
||||
ngon! (5, size)
|
||||
right! (inv (iter))
|
||||
recur (add (size, 1), inc (times), newcolor)
|
||||
}
|
||||
else :ok
|
||||
}
|
||||
}
|
||||
|
||||
& spiral_gon! (100)
|
||||
|
||||
fn spiral_gonr! {
|
||||
(iter) -> spiral_gonr! (iter, iter, 30)
|
||||
(_, 0, _) -> :ok
|
||||
|
@ -20,4 +39,6 @@ fn spiral_gonr! {
|
|||
spiral_gonr! (iter, dec (times), inc (size))
|
||||
}
|
||||
}
|
||||
goto! (37, 37)
|
||||
spiral_gonr! (100)
|
||||
print! (turtle_state())
|
||||
|
|
Loading…
Reference in New Issue
Block a user