This commit is contained in:
Scott Richmond 2024-08-01 17:31:36 -04:00
parent d477782ff6
commit ea80f81c33
3 changed files with 4015 additions and 14 deletions

View File

@ -139,7 +139,7 @@ function command_to_state (prev_state, curr_command) {
return {...prev_state, visible: false} return {...prev_state, visible: false}
} }
case "background": { case "background": {
background_color = curr_command.slice(1) background_color = curr_command[1]
return prev_state return prev_state
} }
} }
@ -332,7 +332,7 @@ export function p5_calls (commands) {
p5_calls.push(call) p5_calls.push(call)
} }
} }
p5_calls[0] = ["background", background_color] p5_calls[0] = ["background", ...resolve_color(background_color)]
p5_render_turtle(states[states.length - 1], p5_calls) p5_render_turtle(states[states.length - 1], p5_calls)
return p5_calls return p5_calls
} }

View File

@ -1,15 +1,15 @@
import {run, svg} from "./ludus.mjs" import {run, svg} from "./ludus.mjs"
const code = ` const code = `
repeat 20 { print! (random ())
repeat 100 { print! (random ())
fd! (4) print! (random ())
rt! (0.01) print! (random ())
} print! (random ())
pencolor! (random (colors)) print! (random ())
rt! (inv (20))
}` `
const result = run(code) const result = run(code)
console.log(svg(result.io.turtle.data)) console.log(result.io.stdout.data)

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 722 B

After

Width:  |  Height:  |  Size: 338 KiB