Reset state after each run
This commit is contained in:
parent
c9ccffa067
commit
efb33cc1be
|
@ -3,9 +3,18 @@
|
||||||
|
|
||||||
if turtle_state() :visible? then render_turtle! () else nil
|
if turtle_state() :visible? then render_turtle! () else nil
|
||||||
|
|
||||||
|
let console_msgs = deref (console)
|
||||||
|
set! (console, [])
|
||||||
|
|
||||||
|
let (r, g, b, a) = deref (bgcolor)
|
||||||
|
set! (bgcolor, colors :black)
|
||||||
|
|
||||||
|
let draw_calls = deref (p5_calls)
|
||||||
|
set! (p5_calls, [])
|
||||||
|
|
||||||
#{
|
#{
|
||||||
& :result result is provided elsewhere
|
& :result result is provided elsewhere
|
||||||
:errors [] & if we get here there are no errors
|
& :errors [] & if we get here there are no errors
|
||||||
:console deref (console)
|
:console console_msgs
|
||||||
:draw deref (p5_calls)
|
:draw concat ([(:background, r, g, b, a)], draw_calls)
|
||||||
}
|
}
|
|
@ -658,12 +658,13 @@ fn range {
|
||||||
|
|
||||||
&&& Turtle & other graphics
|
&&& Turtle & other graphics
|
||||||
let colors = @{
|
let colors = @{
|
||||||
:white (255, 255, 255)
|
:white (255, 255, 255, 255)
|
||||||
:light_gray (150, 150, 150)
|
:light_gray (150, 150, 150, 255)
|
||||||
:dark_gray (50, 50, 50)
|
:dark_gray (50, 50, 50, 255)
|
||||||
:red (255, 0, 0)
|
:red (255, 0, 0, 255)
|
||||||
:green (0, 255, 0)
|
:green (0, 255, 0, 255)
|
||||||
:blue (0, 0, 255)
|
:blue (0, 0, 255, 255)
|
||||||
|
:black (0, 0, 0, 255)
|
||||||
}
|
}
|
||||||
|
|
||||||
& the initial turtle state
|
& the initial turtle state
|
||||||
|
@ -683,11 +684,9 @@ ref turtle_commands = []
|
||||||
& and a list of turtle states
|
& and a list of turtle states
|
||||||
ref turtle_states = [turtle_init]
|
ref turtle_states = [turtle_init]
|
||||||
|
|
||||||
ref p5_calls = [
|
ref p5_calls = []
|
||||||
(:background, 0)
|
|
||||||
]
|
|
||||||
|
|
||||||
ref bgcolor = (0, 0, 0, 255)
|
ref bgcolor = colors :black
|
||||||
|
|
||||||
fn add_call! (call) -> update! (p5_calls, append (_, call))
|
fn add_call! (call) -> update! (p5_calls, append (_, call))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user