Skip to content

Respect layer colours#31

Open
MarkJB wants to merge 5 commits intomainfrom
respect-layer-colours
Open

Respect layer colours#31
MarkJB wants to merge 5 commits intomainfrom
respect-layer-colours

Conversation

@MarkJB
Copy link
Copy Markdown
Member

@MarkJB MarkJB commented Apr 3, 2026

This pull request enhances SVG import and rendering by improving how layer and path stroke colors are detected, inherited, and rendered. It adds robust support for Inkscape layer markers, ensures stroke colors are captured from both layers and paths (including inherited styles), and updates the rendering logic to use these colors for more accurate visual output. The changes also introduce new tests to cover these behaviors.

image

Note: Colours are overridden by the apps own layer colours:
image

SVG Import and Layer Detection Improvements:

  • Added detection of Inkscape layer groups using the inkscape:groupmode="layer" attribute, allowing SVGs created in Inkscape to be properly imported with their logical layers recognized. [1] [2]
  • Updated the logic to treat groups as layers if they have explicit display styling or an Inkscape layer marker, rather than just explicit display. [1] [2]

Stroke Color Inheritance and Normalization:

  • Implemented functions to resolve and normalize stroke colors, capturing inherited stroke colors from ancestor groups for both layers and individual paths. [1] [2] [3]
  • Extended the SvgPath and SvgLayer types to store the resolved sourceStrokeColor for use in rendering. [1] [2]

Rendering Logic Enhancements:

  • Refactored the rendering logic in PlotCanvas to bucket outlines and hatches by color, and to use the correct stroke colors for each path or layer, including selection highlighting. [1] [2] [3] [4] [5]

Testing and Validation:

  • Added comprehensive tests to verify detection of Inkscape layers, correct mapping of layer IDs, inheritance of stroke colors, and exclusion of plain groups from layer detection.

These changes result in more accurate and visually faithful SVG imports, especially for files created in Inkscape or using complex group structures.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

PR build artifacts are ready:

These artifacts are temporary and are deleted automatically when the PR is closed.

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