Skip to content

fix SVG preserveAspectRatio="none" handling for <symbol>/<use> - #9261

Open
Danyccsf wants to merge 2 commits into
processing:mainfrom
Danyccsf:fix-svg-preserve-aspect-ratio-none
Open

Danyccsf wants to merge 2 commits into
processing:mainfrom
Danyccsf:fix-svg-preserve-aspect-ratio-none

Conversation

@Danyccsf

@Danyccsf Danyccsf commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Resolves #9257

Changes:

  • Respect preserveAspectRatio="none" when a <use> element references a <symbol> with a viewBox.
  • Apply independent X and Y scaling instead of the default uniform xMidYMid meet scaling in this case.
  • Account for non-zero viewBox origins when applying the transform.
  • Preserve the existing default xMidYMid meet behavior for other cases.
  • Add regression tests for non-uniform scaling and a non-zero viewBox origin.

Screenshots of the change:
N/A — this change is covered by SVG importer unit tests.

PR Checklist

@p5-bot

p5-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

Continuous Release

CDN link

Published Packages

Commit hash: 691e886

Previous deployments

This is an automated message.

@davepagurek davepagurek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good! Do you think we could add some visual tests so it's easier to verify the output?

I also was looking at https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/preserveAspectRatio to see what other options there are than none. Do you have a sense of what it might take to fully cover this attribute and whether that's worth adding?

@Danyccsf

Danyccsf commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

This is looking good! Do you think we could add some visual tests so it's easier to verify the output?

I also was looking at https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/preserveAspectRatio to see what other options there are than none. Do you have a sense of what it might take to fully cover this attribute and whether that's worth adding?

Thanks, Dave! I appreciate the feedback.

I'll look into the existing visual testing setup and add appropriate visual coverage for this case.

I'll also review the other preserveAspectRatio options and assess the scope of supporting them, so we can decide whether they belong in this PR or would be better handled separately.

I'll follow up with my findings!

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.

[p5.js 2.0+ Bug Report]: SVG importer does not respect preserveAspectRatio="none" for <symbol>/<use>

2 participants