From b0d0e41ddc0b68710aa1d89f3f3a4dd15d6a9321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 12 Jun 2016 18:21:37 +0200 Subject: [PATCH] Allow negative offsets in all Curve#get*At() methods. To search from the end of the curve instead of the beginning. --- src/path/Curve.js | 2 +- test/tests/Curve.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index 456f3510..e5ef3718 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1261,7 +1261,7 @@ new function() { // Injection scope for various curve evaluation methods this[name + 'At'] = function(location, _isTime) { var values = this.getValues(); return Curve[name](values, _isTime ? location - : Curve.getTimeAt(values, location, 0)); + : Curve.getTimeAt(values, location)); }; this[name + 'AtTime'] = function(time) { diff --git a/test/tests/Curve.js b/test/tests/Curve.js index 8e1e6aed..899736fb 100644 --- a/test/tests/Curve.js +++ b/test/tests/Curve.js @@ -163,12 +163,16 @@ test('Curve#getTimeAt()', function() { var o1 = curve.length * f; var o2 = -curve.length * (1 - f); var message = 'Curve-time parameter at offset ' + o1 - + ' should be the same value as at offset' + o2; + + ' should be the same value as at offset ' + o2; equals(curve.getTimeAt(o1), curve.getTimeAt(o2), message, Numerical.CURVETIME_EPSILON); // Legacy version: equals(curve.getParameterAt(o1), curve.getParameterAt(o2), 'Legacy: ' + message, Numerical.CURVETIME_EPSILON); + equals(curve.getTangentAt(o1), curve.getTangentAt(o2), + 'Tangent at offset ' + o1 + + ' should be the same value as at offset ' + o2, + Numerical.CURVETIME_EPSILON); } equals(curve.getTimeAt(curve.length + 1), null,