Skip to content

Fix viewBox dimensions in SVG creation - #1

Open
noreun wants to merge 1 commit into
das-dias:masterfrom
noreun:noreun-viewbox-patch
Open

Fix viewBox dimensions in SVG creation#1
noreun wants to merge 1 commit into
das-dias:masterfrom
noreun:noreun-viewbox-patch

Conversation

@noreun

@noreun noreun commented May 12, 2026

Copy link
Copy Markdown

Fix SVG viewBox using max coordinates instead of width/height

The viewBox attribute in render_to_svg is set to:

"viewBox": f"{pbot[0]} {pbot[1]} {ptop[0]} {ptop[1]}"

SVG viewBox semantics are min-x min-y width height, not min-x min-y max-x max-y. This causes the rendered SVG to be clipped whenever the design's bounding box doesn't start at the origin.

For example, a design spanning [-200, 200] produces viewBox="-200 0 200 10000" (a 200-unit-wide view starting at -200, clipping everything past x=0).

Fix:

"viewBox": f"{pbot[0]} {pbot[1]} {width_points} {length_points}"

(width_points and length_points are already correctly computed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant