fix penwidth bug
This commit is contained in:
parent
f0d19da532
commit
13856cb8b2
|
@ -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]
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user