mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-13 06:29:11 -04:00
parent
771bb61038
commit
d405f45d38
2 changed files with 13 additions and 1 deletions
|
@ -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));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue