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 drawing problem with a specific file #515

Closed
benfry opened this issue Jul 26, 2022 · 4 comments
Closed

SVG drawing problem with a specific file #515

benfry opened this issue Jul 26, 2022 · 4 comments
Labels
Help Wanted We have very little time and would like some help

Comments

@benfry
Copy link
Owner

benfry commented Jul 26, 2022

Not sure if this is because of the elliptical arc handling or how the path is being closed, but the current (as of 4.0 beta 8) SVG parsing produces this:

Screen Shot 2022-07-26 at 6 45 53 AM

for this file:

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve">
<g><path fill="#9B9B9B" d="M16,0A16,16,0,1,0,32,16,16,16,0,0,0,16,0Zm0,25A8,8,0,0,1,16,9h.59l-2.3-2.29a1,1,0,0,1,1.42-1.42l4,4a1,1,0,0,1,.21.33,1,1,0,0,1,0,.76,1,1,0,0,1-.21.33l-4,4a1,1,0,0,1-1.42,0,1,1,0,0,1,0-1.42L16.59,11H16a6,6,0,1,0,6,6,1,1,0,0,1,2,0A8,8,0,0,1,16,25Z"/></g>
</svg>

Re-saving the file with Illustrator produces this code:

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve">
<g><path fill="#9B9B9B" d="M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M16,25c-4.4,0-8-3.6-8-8s3.6-8,8-8h0.6 l-2.3-2.3c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l4,4c0.1,0.1,0.2,0.2,0.2,0.3c0.1,0.2,0.1,0.5,0,0.8c0,0.1-0.1,0.2-0.2,0.3l-4,4 c-0.4,0.4-1,0.4-1.4,0c0,0,0,0,0,0c-0.4-0.4-0.4-1,0-1.4c0,0,0,0,0,0l2.3-2.3H16c-3.3,0-6,2.7-6,6s2.7,6,6,6s6-2.7,6-6 c0-0.6,0.4-1,1-1s1,0.4,1,1C24,21.4,20.4,25,16,25z"/></g>
</svg>

which renders correctly:

Screen Shot 2022-07-26 at 6 47 48 AM

Probably something fairly simple, just needs someone to start at the path parsing a bit and find what's wrong. (And make sure the fix doesn't break other SVGs).

@benfry
Copy link
Owner Author

benfry commented Jul 31, 2022

This may be the same as #518

@bsapozhnikov
Copy link
Contributor

@benfry Is this issue still of interest?
I repro'd and played with PShapeSVG a bit and it looks like the issue is specifically when there is no delimiter between two numbers in the SVG path, e.g. a 1,1,0,0,1,.21.33. The current code seems to treat .21.33 as a single token, whereas my browser seems to render the same SVG just fine.
I think I'm able to resolve it by keeping track of whether we're already inside a decimal and using that flag to add a separator when encountering a second decimal.
Let me know if a code snippet or PR would be helpful :)

@benfry
Copy link
Owner Author

benfry commented Jan 28, 2023

Yes, that sounds correct. Though I thought that had been fixed already in a previous PR.

But yes, it's still of interest; thank you!

@benfry
Copy link
Owner Author

benfry commented Feb 18, 2023

Integrated the fix from #659 for Processing 4.2.

@benfry benfry closed this as completed Feb 18, 2023
benfry added a commit that referenced this issue Feb 18, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Help Wanted We have very little time and would like some help
Projects
None yet
Development

No branches or pull requests

2 participants