Skip to content

Conversation

hxrshxz
Copy link

@hxrshxz hxrshxz commented Oct 14, 2025

Fixes #1244

Summary

Adds support for compact SVG arc notation where flags and coordinates are concatenated (e.g., a2 2 0 013 3 instead of a 2 2 0 0 1 3 3). Previously crashed with ArrayIndexOutOfBoundsException.

Changes

  • core/src/processing/core/PShapeSVG.java: Added isCompactArcNotation() helper method to detect and parse concatenated arc flags/coordinates for both A and a commands
  • core/test/processing/core/PShapeSVGPathTest.java: Added 4 test cases covering compact notation, standard notation, and edge cases

Before

Screencast.from.2025-10-15.00-31-18.mp4

After

Screencast.from.2025-10-14.23-14-15.mp4

@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 19:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an ArrayIndexOutOfBoundsException that occurred when parsing SVG arc commands with compact notation where flags and coordinates are concatenated (e.g., a2 2 0 013 3). The fix adds support for detecting and properly parsing this compact format.

Key changes:

  • Added isCompactArcNotation() helper method to detect concatenated arc flags and coordinates
  • Modified arc parsing logic for both absolute (A) and relative (a) commands to handle compact notation
  • Added comprehensive test coverage for various compact arc notation scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/processing/core/PShapeSVG.java Implements compact arc notation detection and parsing logic
core/test/processing/core/PShapeSVGPathTest.java Adds test cases for compact notation, standard notation, and edge cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hxrshxz
Copy link
Author

hxrshxz commented Oct 14, 2025

@catilac have a look :)

@Stefterv
Copy link
Collaborator

Hi @hxrshxz great work! Thank you!

Looking at the tests, the one thing I would say to be missing is a step that actually checks if the parsing occurred correctly by looking at the numbers that the parser spits out, I would say just checking if the shape parses is not enough.

@hxrshxz
Copy link
Author

hxrshxz commented Oct 15, 2025

Thanks @Stefterv I have added tests to verify the actual parsed endpoint values, not just that the shape doesn't crash

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.

Loading SVG fails for some files

2 participants