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

stroke path calculation seems broken in certain case #57

Closed
zimond opened this issue Dec 20, 2017 · 10 comments
Closed

stroke path calculation seems broken in certain case #57

zimond opened this issue Dec 20, 2017 · 10 comments
Labels

Comments

@zimond
Copy link
Contributor

zimond commented Dec 20, 2017

<path d="M63,252.1L66.1,249.4L63,246.7" stroke-width="2" stroke="#000000" fill="none"/>

Seems the svg demo renders wrong stroke path. Maybe pathfinder_path_utils::stroke is giving wrong endpoints in this case?

@dylanede
Copy link

I've also bumped into this. Given this SVG (uploaded as a zip since GitHub refuses to attach SVGs):

test_svg.zip

the following output is observed (ignore the clipped bottom of the frame):

image

The correct output should look like this (ignoring discrepancies in line joins, which pathfinder doesn't implement yet):

image

This SVG includes both closed and open paths. Observed issues:

  • Closed paths are not actually getting the last edge added to close them
  • Sometimes the right-most pair of edges in a path get badly triangulated. This doesn't seem to be affected by whether the path is created in a clockwise or anti-clockwise fashion.
  • The top-left path isn't being rendered.
  • All paths are exactly twice as thick as expected.

I have seen similar issues when using Pathfinder in an OpenGL ES renderer I'm working on, with much more complex graphics. The above SVG renders with identical problems in my renderer as well.

@pcwalton What are your thoughts?

@pcwalton
Copy link
Contributor

Interesting, thanks for the report! I'll take a look.

@pcwalton pcwalton added the bug label Dec 20, 2017
pcwalton added a commit that referenced this issue Dec 20, 2017
pcwalton added a commit that referenced this issue Dec 20, 2017
Partially addresses #57.
pcwalton added a commit that referenced this issue Dec 20, 2017
…ting the intersection of self-intersecting line segments.

Partially addresses #57.
@pcwalton
Copy link
Contributor

I believe this is all fixed. Thanks for the bug report!

@dylanede
Copy link

I've checked out the latest commit, and although most of the problems are fixed, the top left spiral shape is still not showing up. Also, the closed black pentagon does not appear to be joining the starting edge with the last edge. This is what I see:

image

@dylanede
Copy link

On further inspection, it appears that the spiral shape only shows up when using XCAA. Under other modes it doesn't appear.

@dylanede
Copy link

dylanede commented Dec 21, 2017

It appears that some new problems have appeared as a result of these fixes.

Before the fixes, this svg (a stroked and filled path generated from some text in Inkscape) looked like this (using XCAA):

image

Now it looks like this:

image

and with no anti-aliasing, it looks like this:

image

For reference, all browsers I tried it on rendered it natively like this:

image

@pcwalton
Copy link
Contributor

pcwalton commented Dec 21, 2017

@dylanede Did you rebuild the demo with npm run build? It was a client-side fix, not a server-side one. The top left path shows up locally for me under all AA modes.

@dylanede
Copy link

Ah, it's possible that I didn't. That could explain it. When I'm back at that machine I'll check.

However with the other problem (the strokes in the "Testing" image) I have seen similar behaviour in my own renderer after updating the dependency on pathfinder, so it's not affected by changes in the client.

pcwalton added a commit that referenced this issue Dec 21, 2017
pcwalton added a commit that referenced this issue Dec 21, 2017
These extra points are unnecessary and can confuse the partitioner,
because they sometimes prevent it from detecting winding numbers
properly. This is a bug in the partitioner and should be fixed, but we
shouldn't be generating these points to begin with.

Partially addresses #57.
@zimond
Copy link
Contributor Author

zimond commented Dec 27, 2017

Seems when using the new stroke logic, every EndPoint.subpath_index is 0 no matter how many subpaths are there in the PathBuffer. Is this a bug?

@zimond
Copy link
Contributor Author

zimond commented Dec 27, 2017

Oops, it seems that I need to consume the stream once again in a new PathBuffer to make the numbers correct. Ignore my last report please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants