mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Some minor clean-ups.
This commit is contained in:
parent
027a5e67b9
commit
3447d11a6f
1 changed files with 6 additions and 5 deletions
|
@ -261,13 +261,14 @@ var Curve = this.Curve = Base.extend({
|
||||||
getPartLength: function(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t, right) {
|
getPartLength: function(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t, right) {
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
var part;
|
||||||
if (t < 1) {
|
if (t < 1) {
|
||||||
curve = Curve.subdivide(p1x, p1y, c1x, c1y, c2x, c2y,
|
part = Curve.subdivide(p1x, p1y, c1x, c1y, c2x, c2y,
|
||||||
p2x, p2y, t)[right ? 1 : 0];
|
p2x, p2y, t)[right ? 1 : 0];
|
||||||
} else {
|
} else {
|
||||||
curve = arguments;
|
part = arguments;
|
||||||
}
|
}
|
||||||
return Curve.getLength.apply(Curve, curve);
|
return Curve.getLength.apply(Curve, part);
|
||||||
},
|
},
|
||||||
|
|
||||||
getParameter: function(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
|
getParameter: function(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
|
||||||
|
@ -280,8 +281,8 @@ var Curve = this.Curve = Base.extend({
|
||||||
// Let's use the Van Wijngaarden–Dekker–Brent Method to find
|
// Let's use the Van Wijngaarden–Dekker–Brent Method to find
|
||||||
// solutions more reliably than with False Position Method.
|
// solutions more reliably than with False Position Method.
|
||||||
function f(t) {
|
function f(t) {
|
||||||
return Curve.getPartLength(
|
return length - Curve.getPartLength(
|
||||||
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) - length;
|
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t);
|
||||||
}
|
}
|
||||||
// Use length / bezierLength for an initial guess for b, to bring
|
// Use length / bezierLength for an initial guess for b, to bring
|
||||||
// us closer:
|
// us closer:
|
||||||
|
|
Loading…
Reference in a new issue