Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG loading causes ArrayIndexOutOfBoundsException with some files #750

Open
villares opened this issue Jul 15, 2023 · 4 comments
Open

SVG loading causes ArrayIndexOutOfBoundsException with some files #750

villares opened this issue Jul 15, 2023 · 4 comments
Labels
Help Wanted We have very little time and would like some help

Comments

@villares
Copy link
Contributor

Description

Loading some SVG files that used to work with loadShape() on Processing 3.5.4 will cause a message like this (the index varies):
ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128

Expected Behavior

image

Current Behavior

image

Steps to Reproduce

  1. Copy this SVG file to a data folder inside a new sketch:
    https://gist.github.com/villares/a5b028eaddf4c0e008f9783ea5dddb40

  2. Paste in and run this code:

void setup(){
 size(200, 200);
 PShape a = loadShape("a.svg");
 shape(a, 0, 0, 200, 200); // optional, will not be reached
}  

Environment

Processing version: Processing 4.2
Operating System and OS version: Manjaro 21.3 Kernel 5.15

More information / ideas

Looks similar to this issue with coordinates starting with .: #518 (comment)

But the offending coordinates seem to be 2.51259,6.5e-4, if I replace with 2.51259,0 it loads.

@benfry benfry added the Help Wanted We have very little time and would like some help label Jul 16, 2023
behreajj added a commit to behreajj/CamZup that referenced this issue Jul 19, 2023
Try fix parsing transforms with commands separated by commas in svgs
benfry/processing4#750
@villares
Copy link
Contributor Author

villares commented Jul 28, 2023

Thank you very much @behreajj!

@SaumyaKarnwal
Copy link

hey @benfry ,
I have resolved the issue and raised a PR.
Please review :)

@luis-c465
Copy link

Was getting this same issue when trying to parse this USA Map with Counties because it contains values like 3.5e-5, 3e-2 etc.

Thank you, @SaumyaKarnwal! 🎉

For the time being I made a simple python script to convert these values into proper decimals, so I can continue on my project 😄.

https://gist.github.com/luis-c465/6c748e40b5c1b8899f5d1502228a5cd6

@SaumyaKarnwal
Copy link

SaumyaKarnwal commented Mar 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted We have very little time and would like some help
Projects
None yet
Development

No branches or pull requests

4 participants