bring in and update postlude

This commit is contained in:
Scott Richmond 2024-06-05 23:23:47 -04:00
parent 176feb5ae2
commit d84a930073
2 changed files with 30 additions and 0 deletions

View File

@ -57,4 +57,9 @@ This new scene will have to return a JSON POJSO:
(-> source run)
)
(comment
Next up:
* postlude!
* testing turtle graphics
)

25
janet/postlude.ld Normal file
View File

@ -0,0 +1,25 @@
& this file runs after any given interpretation
& even if the original interpretation panics
& the goal is to output any global state held in Ludus
& this does not have base loaded into it, only prelude: must be pure Ludus
if turtle_state () :visible? then render_turtle! () else nil
reset_turtle! ()
let console_msgs = flush! ()
let (r, g, b, a) = unbox (bgcolor)
make! (bgcolor, colors :black)
let draw_calls = unbox (p5_calls)
store! (p5_calls, [])
#{
& :result result is provided elsewhere
& :errors [] & if we get here there are no errors
:console console_msgs
:draw concat (
[(:background, r, g, b, a), (:stroke, 255, 255, 255, 255)]
draw_calls)
}