Resolving self-intersecting paths

652 views
Skip to first unread message

Alfie Woodland

unread,
Jan 29, 2014, 6:42:24 PM1/29/14
to pap...@googlegroups.com
I'm getting to grips with paper.js by creating a simple animation tool in the browser, but I've hit an issue. In this tool brush strokes of the same colour are united into a single path, much like in flash; however, as self-intersecting paths aren't yet supported within the boolean operations of paper.js I'm left struggling to find a method to remove these intersections. Picture supplied for reference.

Is there a method within paper.js already which can deal with this case, or am I just going to have to be a little more clever with how the brush strokes are generated?

Any plans to introduce boolean operations for self-intersecting paths in the future?

Thanks!
self-intersect.png

Péter Vívó

unread,
Jan 31, 2014, 5:50:55 AM1/31/14
to pap...@googlegroups.com
try: split your path to segments and test each segments intersection by other segments, then you get all intersections points.

Alfie Woodland

unread,
Feb 5, 2014, 12:47:19 PM2/5/14
to pap...@googlegroups.com
Hey, thanks for the reply.

The only way I can think to do that is if I split the path into an array of paths each containing a single curve and then called getIntersections() for all n! cases, but even a single cubic Bézier curve can self-intersect, so I might not find all of the points. Not to mention the fact that even then there would be the issue of slicing up the path and recombining it correctly.

This problem is way over my head, honestly. I'll just work around it for now, but a method to clean up paths like this would be a really awesome addition to paper.js

Jürg Lehni

unread,
Feb 12, 2014, 3:22:18 AM2/12/14
to pap...@googlegroups.com, Harikrishnan Gopalakrishnan
Hari, here another request for support of self-intersection in the boolean code. That's the same situation as the previous one, right?

--
You received this message because you are subscribed to the Google Groups "Paper.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
<self-intersect.png>

Harikrishnan G.

unread,
Feb 15, 2014, 6:27:02 PM2/15/14
to pap...@googlegroups.com
I think I will be able to find some time to finish it. All the required algorithms are in place now.
You can see the progress here https://groups.google.com/forum/#!topic/paperjs/bJ-e1Fu0MnU

/Hari
Reply all
Reply to author
Forward
0 new messages