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
getBoundingBox improvements #121
Conversation
|
bounds[0].push(p3[0]); | ||
bounds[1].push(p3[1]); | ||
|
||
for (var i = 0; i < 2; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a URL that points to the origin of this approach and if possible add some comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the worst part of the implementation because I am not sure how it works. I ported it from a python script I found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
I tried understanding the math on the article you linked to but in the end, after struggling, I grabbed this and ported it and it seemed to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@padolsey please add his MIT License note to our LICENSE file.
For related issues and discussions:
These should all be closable when this is merged. |
* @param {Matrix} [transform=null] A transform to apply to all points | ||
* before computation. | ||
* @return {Object} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc block still has the key
parameter
Awesome demo. I’ve added a few remarks. Can’t verify the bounds algorithm for cubic bezier curves (no time), but it seems to work. |
…ration (no children)
ready for merge? further objections? |
Just to note: This pull request does not fix #2 |
@padolsey very nice demo, indeed! 👍 |
What was previously the
getComputed
method is nowgetBoundingBox
.It takes on optional argument, a
Matrix
instance which will be used to apply transforms to the calculated bounding-box.getBoundingBox
always returns an object in the form:Included in this pull request is also an algorithm to determine the correct extrema of cubic bezier curves. Checkout the branch and open the
bounding-box.js
example to see a demonstration of the newgetBoundingBox
calculation.