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

Add Line.getDistance() and use it in Curve.getOverlaps() #1253

Merged
merged 1 commit into from Feb 11, 2017

Conversation

iconexperience
Copy link
Contributor

@iconexperience iconexperience commented Feb 7, 2017

Added a static function getDistance() to line, that simply calls Line.getSignedDistance() and returns the absolute value. This makes the Line API a bit more symmetrical, which already has the mathod getDistance for the Line prototype.

In Curve.getOverlaps() we create a new instance of Line and at least one instance of Point to check if the two curves are overlapping lines. This is done for each pair of curves and the result is false in the vast majority of cases. Since this generates quite a lot of garbage for little effect, so I though it would be nice to implement a way that does the same without producing garbage. Also, the new code is smaller when minified, so this compensates a little bit for the extra code in Line.

@lehni
Copy link
Member

lehni commented Feb 11, 2017

Yes this makes a lot of sense. Thanks for spotting! We may want to use this approach in other parts too, e.g. in the code that calculates strokeBounds...

@lehni lehni merged commit 5736eba into paperjs:develop Feb 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants