artursapek / mondrian

Web-based vector graphics editor
MIT License
1.24k stars 104 forks source link

Consider using Clipper library instead of geometry/pathfinder.coffee #11

Open jarek-foksa opened 10 years ago

jarek-foksa commented 10 years ago

Path clipping is a tough mathematical problem that requires some non-trivial code. Instead of trying to do it yourself I would use JavaScript Clipper [1] library. Clipper doesn't have full support for Beziers yet (it's being worked on in the upstream branch, for now you would need to convert beziers to polygons), though it would be much more reliable than the current code in geometry/pathfinder.coffee.

[1] http://sourceforge.net/projects/jsclipper/

artursapek commented 10 years ago

Pathfinder was the bit that I was still working on when I decided to open this project up. It's not available through the UI yet because it's so unfinished. In fact it should be on a seperate feature branch.

It's been by far the hardest part of building Mondrian. That also means it's the most interesting, so I definitely want to have a native pathfinder implementation in the codebase. I think having a pathfinder utility would be great, but it's not a top priority right now so I'm not in a hurry to get it out.

For the time being I'll check out clipper. If it's not too hard to get it to work in a way that feels "native" I'll consider merging something temporary in, but if it doesn't support beziers yet then I don't think there's much of a chance. Thanks for the suggestion.

wraybowling commented 10 years ago

Paper JS had similar woes but later on they merged in another boolean library's functions that were really great. It was an interesting read when it happened. I'm having a hard time finding links now, but just sayin' it's out there. Somewhere. (Also, paperjs is on github. So there's that.)— Sent from Mailbox for iPhone

On Sat, Jan 25, 2014 at 10:01 AM, Artur Sapek notifications@github.com wrote:

Pathfinder was the bit that I was still working on when I decided to open this project up. It's not available through the UI yet because it's so unfinished. In fact it should be on a seperate feature branch. It's been by far the hardest part of building Mondrian. That also means it's the most interesting, so I definitely want to have a native pathfinder implementation in the codebase. I think having a pathfinder utility would be great, but it's not a top priority right now so I'm not in a hurry to get it out.

For the time being I'll check out clipper. If it's not too hard to get it to work in a way that feels "native" I'll consider merging something temporary in, but if it doesn't support beziers yet then I don't think there's much of a chance. Thanks for the suggestion.

Reply to this email directly or view it on GitHub: https://github.com/artursapek/mondrian/issues/11#issuecomment-33290740

artursapek commented 10 years ago

I have an attack strategy for Pathfinder - I think I have the algorithm worked out on paper. I'm working on visual documentation at artur.co/pathfinder.

I just haven't finished implementing it yet because there were some problems with the implementation of the linked list that stores a path's points. I don't think it's too far off if I focus on it for a while.