-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
weirdly displaced vertices in SVG #5523
Comments
Okay, it seems that it was an issue with the SVG. I have optimized it - closed all paths, removed unneccessary verts, and now it works. This still doesn't change the fact that the renderer can't handle broken SVGs (whereas Webkit and others can), and this should be fixed. |
Regarding the crashSo, according to the SVG spec, I have come to the conclusion that:
([+-]?[\d]+(\.[\d]+)?([eE][+-][\d]+)?)(,?\s*)([+-]?[\d]+(\.[\d]+)?([eE][+-][\d]+)?) Tested with RegExr We can then extract the X coord from group 1, and the Y coord from group 5. Here's the regex explained: ( # Match a number for the X coordinate
[+-]? # Optional + or - in front of the number
[\d]+ # Sequence of digits, forming an integer
(\.[\d]+)? # Optionally, there can be a dot, and another sequence of digits for a floating point decimal
([eE][+-][\d]+)? # After the whole digit, optionally, there can be an exponent, like e+2
)
( # Match the delimiter between two coords
,? # The optional comma
\s* # 0 or more spaces
)
([+-]?[\d]+(\.[\d]+)?([eE][+-][\d]+)?) # Match another number, same as group 1 The expression will match old style patterns, like Why is this?The
Source: SVG spec Hopefully this shouldn't be too hard to implement. I'll have my own try at this, and submit a PR. |
(Somewhat offtopic) UpdateI might take a shot at this (for FX2D), but it would require a bit of a rewrite of how How this could potentially be fixedI was learning about the JavaFX I am unsure about the original problem, but I'll definitely look into it now that I've got a better understanding of how Processing is structured internally. |
Hi. I am facing a similar issue. I exported svg consisting numerous rotated rectangles stacked diagonally but when I import it back as svg in processing, they come out misaligned. |
Rolling SVG requests into #5935 |
Description
I am trying to draw this file onto the screen, but the vertices are weirdly displaced.
Expected Behavior
The vertices should be drawn correctly, as seen in the Gist.
Current Behavior
Look at the shape on the right side. This happens in all circumstances, no matter if I scale it, translate it, apply a custom fill, it just always happens.
P2D and P3D crash when trying to draw the SVG, with a tesselation error "out of memory".
FX2D doesn't handle the SVG at all, and it looks like garbage:
I have also tried drawing this SVG, and it just crashes my sketch.
Update
I tried to split the shape in half, and the sketch just crashes with the following stack trace:
(I use Processing in IntelliJ and my sketch is in a separate package, that's why there is
iliquid.excircuit.IconBank.load
, and notexCircuit$IconBank.load
(or something like that))Steps to Reproduce
Create a sketch that draws the problematic SVG.
Your Environment
Possible Causes/Solutions
I have been debugging for a bit of time, and I seem to have found the issue (only for the analog.svg crash, but that's still some progress):
https://github.com/processing/processing/blob/master/core/src/processing/core/PShapeSVG.java#L449-L464
Illustrator seems to export SVGs in a format that's different than Processing expects, take a peek at this part of the SVG:
The points are formatted differently than Processing expects them to be. After a ton of debugging, I have came to the conclusion, that those two are the problematic lines of code:
https://github.com/processing/processing/blob/master/core/src/processing/core/PShapeSVG.java#L455
https://github.com/processing/processing/blob/master/core/src/processing/core/PShapeSVG.java#L459
And especially the second one. Line 455 splits the string by spaces, which yields an array like
["18.72", "4", "13.39"...]
, but this causes problems in the next few lines of code:https://github.com/processing/processing/blob/master/core/src/processing/core/PShapeSVG.java#L459-L461
Lines 460 and 461 expect two array entries, but because of the first array, it can't find them.
I have no idea if this is an Illustrator or Processing issue, I am just pointing out what I found.
The text was updated successfully, but these errors were encountered: