diff --git a/src/path/Curve.js b/src/path/Curve.js index 33bc7a68..026e6ce0 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -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;