Compare commits
No commits in common. "14e4cf93ae1615623f9a7312fdfb8e6e99903492" and "ee54da03050573e9659451ce0350d9c127945a98" have entirely different histories.
14e4cf93ae
...
ee54da0305
|
@ -79,7 +79,7 @@ export function svg (commands, code) {
|
||||||
const new_state = command_to_state(prev_state, this_command)
|
const new_state = command_to_state(prev_state, this_command)
|
||||||
all_states[turtle_id].push(new_state)
|
all_states[turtle_id].push(new_state)
|
||||||
}
|
}
|
||||||
let maxX = 0, maxY = 0, minX = 0, minY = 0
|
let maxX = -Infinity, maxY = -Infinity, minX = Infinity, minY = Infinity
|
||||||
for (const states of Object.values(all_states)) {
|
for (const states of Object.values(all_states)) {
|
||||||
for (const {position: [x, y]} of states) {
|
for (const {position: [x, y]} of states) {
|
||||||
maxX = Math.max(maxX, x)
|
maxX = Math.max(maxX, x)
|
||||||
|
@ -90,8 +90,8 @@ export function svg (commands, code) {
|
||||||
}
|
}
|
||||||
const [r, g, b] = resolve_color(background_color)
|
const [r, g, b] = resolve_color(background_color)
|
||||||
if ((r+g+b)/3 > 128) set_turtle_color([0, 0, 0, 150])
|
if ((r+g+b)/3 > 128) set_turtle_color([0, 0, 0, 150])
|
||||||
const view_width = Math.max((maxX - minX) * 1.2, 200)
|
const view_width = (maxX - minX) * 1.2
|
||||||
const view_height = Math.max((maxY - minY) * 1.2, 200)
|
const view_height = (maxY - minY) * 1.2
|
||||||
const margin = Math.max(view_width, view_height) * 0.1
|
const margin = Math.max(view_width, view_height) * 0.1
|
||||||
const x_origin = minX - margin
|
const x_origin = minX - margin
|
||||||
const y_origin = -maxY - margin
|
const y_origin = -maxY - margin
|
||||||
|
|
Loading…
Reference in New Issue
Block a user