fix penwidth bug

This commit is contained in:
Scott Richmond 2024-10-23 16:44:51 -04:00
parent f0d19da532
commit 13856cb8b2
2 changed files with 3 additions and 1 deletions

View File

@ -121,7 +121,7 @@ function command_to_state (prev_state, curr_command) {
case "pendown": { case "pendown": {
return {...prev_state, pendown: true} return {...prev_state, pendown: true}
} }
case "pendwith": { case "penwidth": {
const [_, width] = curr_command const [_, width] = curr_command
return {...prev_state, penwidth: width} return {...prev_state, penwidth: width}
} }
@ -349,6 +349,7 @@ export function p5 (commands) {
states.push(new_state) states.push(new_state)
return new_state return new_state
}, turtle_init) }, turtle_init)
console.log(states)
const p5_calls = [...p5_call_root] const p5_calls = [...p5_call_root]
for (let i = 1; i < states.length; ++i) { for (let i = 1; i < states.length; ++i) {
const prev = states[i - 1] const prev = states[i - 1]

View File

@ -4,6 +4,7 @@ const code = `
print! ("Hello, world!") print! ("Hello, world!")
pencolor! (colors :white) pencolor! (colors :white)
fd! (50) fd! (50)
pw! (3)
` `
const result = run(code) const result = run(code)