show and hide turtle
This commit is contained in:
parent
b9e721e4e2
commit
98180507e4
14
prelude.ld
14
prelude.ld
|
@ -1252,6 +1252,16 @@ fn setheading! {
|
||||||
(heading as :number) -> add_command! ((:setheading, heading))
|
(heading as :number) -> add_command! ((:setheading, heading))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn showturtle! {
|
||||||
|
"If the turtle is hidden, shows the turtle. If the turtle is already visible, does nothing."
|
||||||
|
() -> add_command! ((:show))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hideturtle! {
|
||||||
|
"If the turtle is visible, hides it. If the turtle is already hidden, does nothing."
|
||||||
|
() -> add_command! ((:hide))
|
||||||
|
}
|
||||||
|
|
||||||
fn heading/vector {
|
fn heading/vector {
|
||||||
"Takes a turtle heading, and returns a unit vector of that heading."
|
"Takes a turtle heading, and returns a unit vector of that heading."
|
||||||
(heading) -> {
|
(heading) -> {
|
||||||
|
@ -1288,6 +1298,8 @@ fn apply_command {
|
||||||
(:penwidth, pixels) -> assoc (state, :penwidth, pixels)
|
(:penwidth, pixels) -> assoc (state, :penwidth, pixels)
|
||||||
(:pencolor, color) -> assoc (state, :pencolor, color)
|
(:pencolor, color) -> assoc (state, :pencolor, color)
|
||||||
(:setheading, heading) -> assoc (state, :heading, heading)
|
(:setheading, heading) -> assoc (state, :heading, heading)
|
||||||
|
(:show) -> assoc (state, :visible?, true)
|
||||||
|
(:hide) -> assoc (state, :visible?, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1396,6 +1408,7 @@ pkg Prelude {
|
||||||
gte? & math
|
gte? & math
|
||||||
heading & turtles
|
heading & turtles
|
||||||
heading/vector & math
|
heading/vector & math
|
||||||
|
hideturtle! & turtles
|
||||||
home! & turtles
|
home! & turtles
|
||||||
inc & math
|
inc & math
|
||||||
inv & math
|
inv & math
|
||||||
|
@ -1465,6 +1478,7 @@ pkg Prelude {
|
||||||
set? & sets
|
set? & sets
|
||||||
setheading! & turtles
|
setheading! & turtles
|
||||||
show & strings
|
show & strings
|
||||||
|
showturtle! & turtles
|
||||||
sin & math
|
sin & math
|
||||||
slice & lists tuples strings
|
slice & lists tuples strings
|
||||||
some & values
|
some & values
|
||||||
|
|
|
@ -49,10 +49,11 @@
|
||||||
(set (out :draw) (post :draw))
|
(set (out :draw) (post :draw))
|
||||||
(-> out j/encode string))
|
(-> out j/encode string))
|
||||||
|
|
||||||
(comment
|
# (comment
|
||||||
# (do
|
(do
|
||||||
(def source `
|
(def source `
|
||||||
butlast ([1, 2, 3])
|
hideturtle! ()
|
||||||
|
showturtle! ()
|
||||||
`)
|
`)
|
||||||
(def out (-> source
|
(def out (-> source
|
||||||
ludus
|
ludus
|
||||||
|
|
Loading…
Reference in New Issue
Block a user