From 479e3043575e4bd9a17f524af24baa15a8f40822 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Thu, 1 Aug 2024 18:35:28 -0400 Subject: [PATCH] fix viewBox math so we see just what is there --- build/ludus.mjs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/ludus.mjs b/build/ludus.mjs index 7297505..eb7f3fb 100644 --- a/build/ludus.mjs +++ b/build/ludus.mjs @@ -267,17 +267,17 @@ export function svg (commands) { }, {maxX: 0, maxY: 0, minX: 0, minY: 0}) const [r, g, b, a] = resolve_color(background_color) - const view_width = maxX - minX - const view_height = maxY - minY + const view_width = (maxX - minX) * 1.2 + const view_height = (maxY - minY) * 1.2 const margin = Math.max(view_width, view_height) * 0.1 - const x1 = Math.min(-300, (minX - margin)) - const y1 = Math.min(-300, (minY - margin)) - const x2 = Math.max(600, (maxX + margin)) - const y2 = Math.max(600, (maxY + margin)) + const x1 = minX - margin + const y1 = minY - margin + const x2 = maxX + margin + const y2 = maxY + margin const path = svg_render_path(states) const turtle = svg_render_turtle(states[states.length - 1]) return ` - + ${path} @@ -316,7 +316,7 @@ function p5_render_turtle (state, calls) { return calls } -export function p5_calls (commands) { +export function p5 (commands) { const states = [turtle_init] commands.reduce((prev_state, command) => { const new_state = command_to_state(prev_state, command)