[p5.js 2.0+ Bug Report]: SVG importer does not respect preserveAspectRatio="none" for <symbol>/<use>
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 83/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
- Domain
- computer-graphics
Research direction
Start with the <defs> and <use> elements suite in test/unit/svg/svg_import.js and run npm test -- test/unit/svg/svg_import.js to confirm the failure. Trace how the SVG importer handles preserveAspectRatio for a symbol referenced by <use>. Done means the regression test passes with horizontal transform 2 and vertical transform 1.
Written by the indexing model from the issue text.
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- WebGPU
- p5.strands
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.3.2
Web browser and version
No response
Operating system
macOS 15.7.3
Steps to reproduce this
Steps:
- Add the regression test below to the
<defs> and <use> elementssuite intest/unit/svg/svg_import.js. - Run
npm test -- test/unit/svg/svg_import.js. - Observe that the test fails because
node.state.transform.ais1instead of the expected2.
The test uses a 100×100 <symbol> with preserveAspectRatio="none" inside a 200×100 <use> viewport. In this case, the expected transform is non-uniform scaling: 2× horizontally and 1× vertically.
I reproduced this on p5.js 2.3.2 (main at 7f9e0fda5). The SVG importer test suite reports 92 passing tests and this test failing with:
AssertionError: expected 1 to be close to 2 +/- 0.001
Snippet:
test('use respects preserveAspectRatio=none', function () {
const record = createSVG(`
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol id="stretch" viewBox="0 0 100 100" preserveAspectRatio="none">
<rect x="0" y="0" width="100" height="100" />
</symbol>
</defs>
<use href="#stretch" width="200" height="100" />
</svg>
`);
const scope = firstChild(record);
const node = scope.children[0];
assert.closeTo(node.state.transform.a, 2, 0.001);
assert.closeTo(node.state.transform.d, 1, 0.001);
});
- Dominant language
- JavaScript
- Stars
- 24.1k
- Forks
- 3.9k
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 33
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from processing/p5.js
-
Add unit tests for noiseDetail()Possibly taken @Pcmhacker-piro claimed this 2 days ago. OpenArea:Math Enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
processing/p5.js#9253 ·
Maintainers usually reply within 2 days
-
[p5.js 2.0+ Bug Report]: storeItem() validation branches are missing `return`, so bad input throws a TypeError or is stored anywayPossibly taken @iUjjwalRaj claimed this 2 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
processing/p5.js#9242 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
processing/p5.js#9241 ·
Maintainers usually reply within 2 days
-
[p5.js 2.0+ Bug Report]: Typo in Spanish reference documentation for ellipseMode()Possibly taken @cgutierrezval claimed this 5 days ago. OpenInternationalization p5.js 2.0+
Difficulty 1/5 Under an hour Newbie friendliness 95/100
processing/p5.js#9231 · 3 comments ·
Maintainers usually reply within 2 days
-
[p5.js 2.0+ Bug Report]: ReferenceError: p5 is not defined when calling loadPixels/get/copy/mask on p5.MediaElement in ESMPossibly taken @Pcmhacker-piro claimed this 10 days ago. OpenArea:Core Area:DOM
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
processing/p5.js#9189 · 1 comment ·
Maintainers usually reply within 2 days
All issues in processing/p5.js
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
answerLoops/answerLoops#344 ·
Maintainers usually reply within 1 day
-
Engineering
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
techmatters/terraso-web-client#3095 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Service process inherits the caller's cwd at first use, holding that folder open on Windows (EBUSY)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/viewer#3424 · 1 comment ·
Maintainers usually reply within 1 day