Correctly handle offset in Curve#divideAt(offset)

Closes 
This commit is contained in:
Jürg Lehni 2016-12-31 00:34:37 +01:00
parent 771bb61038
commit d405f45d38
2 changed files with 13 additions and 1 deletions
src/path
test/tests

View file

@ -451,7 +451,7 @@ var Curve = Base.extend(/** @lends Curve# */{
// Accept offsets and CurveLocation objects, as well as objects that act
// like them.
return this.divideAtTime(location && location.curve === this
? location.time : location);
? location.time : this.getTimeAt(location));
},
/**

View file

@ -302,3 +302,15 @@ test('Curve#getPartLength() with straight curve', function() {
equals(function() { return curve.getPartLength(0.5, 0.75); }, 22);
equals(function() { return curve.getPartLength(0.75, 1); }, 10);
});
test('Curve#divideAt(offset)', function() {
var point1 = new Point(0, 0);
var point2 = new Point(100, 0);
var middle = point1.add(point2).divide(2);
equals(function() {
return new Curve(point1, point2).divideAt(50).point1;
}, middle);
equals(function() {
return new Curve(point1, point2).divideAtTime(0.5).point1;
}, middle);
});