mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Switch to new Curve.getParameterOf()
Simpler code, but improved precision means more glitches to analyze.
This commit is contained in:
parent
48bb0a1be4
commit
688f580b95
1 changed files with 16 additions and 1 deletions
|
@ -615,7 +615,7 @@ statics: {
|
|||
return Numerical.solveCubic(a, b, c, p1 - val, roots, min, max);
|
||||
},
|
||||
|
||||
getParameterOf: function(v, point) {
|
||||
getParameterOf_: function(v, point) {
|
||||
// Handle beginnings and end separately, as they are not detected
|
||||
// sometimes.
|
||||
var x = point.x,
|
||||
|
@ -666,6 +666,21 @@ statics: {
|
|||
return null;
|
||||
},
|
||||
|
||||
getParameterOf: function(v, point) {
|
||||
var coords = [point.x, point.y],
|
||||
roots = [];
|
||||
for (var c = 0; c < 2; c++) {
|
||||
var count = Curve.solveCubic(v, c, coords[c], roots, 0, 1);
|
||||
for (var i = 0; i < count; i++) {
|
||||
var t = roots[i],
|
||||
pt = Curve.getPoint(v, t);
|
||||
if (point.isClose(pt, /*#=*/Numerical.GEOMETRIC_EPSILON))
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
// TODO: Find better name
|
||||
getPart: function(v, from, to) {
|
||||
var flip = from > to;
|
||||
|
|
Loading…
Reference in a new issue