Skip to content

M4: SVG import keeps symbols, patterns and filters live; linked images, nested clips, reflected gradients (M4.41, M4.42) - #94

Merged
bflatastic merged 2 commits into
mainfrom
pr/m4-svg-import-live
Oct 5, 2026
Merged

bflatastic merged 2 commits into
mainfrom
pr/m4-svg-import-live

Conversation

@bflatastic

Copy link
Copy Markdown
Member

Part of M4 (Files). SVG import keeps symbols, patterns and blur/shadow filters live, finds linked images in the SVG's folder, intersects nested clips, keeps hidden objects and expands reflected gradients.

  • M4.41: symbols, patterns and filters stay live.
    • Symbols: <symbol> with <use> imports as one symbol (named from data-name, else its id) with an instance per <use>.
    • Patterns: <pattern> imports as a pattern swatch (already on main; now covered by a checker test).
    • Filters: feGaussianBlur, feDropShadow and the common shadow chains (offset / blur / flood or colour matrix / composite / merge) become live Gaussian Blur, Drop Shadow, Outer Glow, Inner Glow and Feather effects. Other filters still warn.
    • Round trip: export writes data-name on <symbol> and data-vc-blend on shadow and glow filters, so export → import → export is stable.
  • M4.42: linked images, clips, hidden objects, reflected gradients.
    • Linked images: document.open {path} and Place find an SVG's relative <image> links in its folder (or the folder in name with dataBase64).
    • Library API: ImportOptions {folder, read} and import_with. The library itself no longer reads any file; before, hrefs were resolved against the working directory.
    • Other import changes:
      • Nested clip paths intersect.
      • Every display:none object comes back hidden.
      • spreadMethod reflect and repeat are expanded into stops, matching resvg in a pixel test.

Known limits:

  • Non-local hrefs (http and the like) become missing-link placeholders.
  • Text inside an SVG used as an image isn't imported (with a warning).
  • A blur with different x/y spreads is read as their average.
  • A <use> with a filter stays plain art.

Checks

Rebased onto 3e8c8d6 (#93). cargo xtask ci passes all 7 steps (fmt, clippy, test, assets, brands, layers, wasm): 2,393 tests, 0 failed.

  • Nothing dropped:
    • every test name on main still exists (2,362 → 2,388);
    • command ids, UI_COMMANDS, menu entries and MCP tools are unchanged.
  • Changed tests, from the intended behaviour:
    • hidden_text_is_skipped_and_use_instances_are_kept: hidden text now comes back hidden.
    • three_instances_give_one_symbol_and_three_uses: the read-back is now one symbol with three instances.
    • an_svg_edited_elsewhere_opens_as_plain_svg_with_a_warning: a plain import now has symbols.

🤖 Generated with Claude Code

bflatastic and others added 2 commits October 5, 2026 12:11
<symbol> with <use> imports as a symbol (named after data-name or its id)
with one instance per <use>; a <use> that shows the symbol differently
(inherited paint, a viewport that cuts it) or that the canvas would paint
differently under its transform stays plain art. feGaussianBlur,
feDropShadow and the usual shadow chains (offset, blur, flood or colour
matrix, composite, merge) become Gaussian Blur, Drop Shadow, Outer/Inner
Glow and Feather effects; other filters are still reported. Export records
the symbol name and the shadow/glow blend mode so export -> import keeps
them. <pattern> keeps importing as a pattern swatch (now tested).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts nested clips, keeps hidden objects and expands reflected gradients

document.open {path} (and File > Place) find an SVG's relative <image>
links in its folder: raster files stay linked images (LinkInfo with size,
time and hash), SVG files and data: SVGs import as vector art, and a file
that can't be read becomes a placeholder in its box that keeps the link,
with a warning and a missingLinks row (Update Links / Relink read it
later). The SVG library itself reads no file unless given a reader.
Nested clip paths become clip groups in clip groups; undisplayed objects
(display:none) come back hidden; spreadMethod reflect and repeat are
expanded into stops over the painted area (matching resvg). Midpoint stops
and focal points keep folding back as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic merged commit 7aee3bd into main Oct 5, 2026
@bflatastic
bflatastic deleted the pr/m4-svg-import-live branch October 5, 2026 05:25
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