mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Allow negative offsets in all Curve#get*At() methods.
To search from the end of the curve instead of the beginning.
This commit is contained in:
parent
7404485f96
commit
b0d0e41ddc
2 changed files with 6 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue