Skip to content

editor: SVG export, drawing frame optional (0.11) - #31

Merged
jonasblixt merged 3 commits into
masterfrom
svg-export
Oct 24, 2026
Merged

jonasblixt merged 3 commits into
masterfrom
svg-export

Conversation

@jonasblixt

Copy link
Copy Markdown
Owner

File › Export SVG… writes the sheet on screen (the root sheet or an off-page sheet) as an SVG file.

  • One drawing code. svg.ts is a Canvas 2D context that records SVG. It covers the calls render.ts and icons.ts make: paths, arcs, rects, text, nested clips, translate/scale and dashes. The export runs renderSheet on it, so the file matches what the editor draws. Text widths come from the editor's canvas fonts.
  • Look. The export uses the active theme in its light appearance, on paper. It leaves out the grid, the selection, handles, problem badges and the simulator highlight. It is drawn at the paper's scale (2 units per pt), so an A3 sheet comes out 1190 × 842 pt and prints 1:1.
  • Drawing frame: optional, on by default. With the frame, the file is the whole sheet: frame, zones and title block. Without it, the file is the diagram's bounds plus a 20-unit margin. You can switch it in three places: File › Export with Drawing Frame (a checked menu item), Settings › Export, or exportFrame in settings.json (written only when false).
  • File names. The file is named after the model: dimmer.svg, or canvas-sheet3.svg for sheet 3.
  • Version. Bumped to 0.11.0.

Tests: export-svg.test.ts (9 tests: the context, both exports, an off-page sheet of canvas.ufsm, the editor's colors restored, file names, the setting). The browser check has 13 new checks: the file parses, its text advances equal the canvas's, it is rasterized and checked, and the menu, the setting and the download work. It passed in full: 455 passed, 0 failed. npm test, typecheck and format:check are green on Windows.

Still to try: the Tauri save dialog in npm run dev, and opening the file in Inkscape.

File › Export SVG… writes the sheet shown, drawn by the canvas renderer on an SVG recording context, in the theme's light colors at the paper's scale. The frame and title block are included unless File › Export with Drawing Frame (or Settings › Export) is off.
@jonasblixt
jonasblixt merged commit e6492e1 into master Oct 24, 2026
10 checks passed
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