mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
parent
7c24fc916f
commit
e2bc83af5d
2 changed files with 16 additions and 2 deletions
|
@ -1338,8 +1338,12 @@ new function() { // Scope for methods that require private functions
|
|||
if (type === 0) {
|
||||
// type === 0: getPoint()
|
||||
// Calculate the curve point at parameter value t
|
||||
x = t === 1 ? p2x : ((ax * t + bx) * t + cx) * t + p1x;
|
||||
y = t === 1 ? p2y : ((ay * t + by) * t + cy) * t + p1y;
|
||||
// Use special handling at t === 0 / 1, to avoid imprecisions.
|
||||
// See #960
|
||||
x = t === 0 ? p1x : t === 1 ? p2x
|
||||
: ((ax * t + bx) * t + cx) * t + p1x;
|
||||
y = t === 0 ? p1y : t === 1 ? p2y
|
||||
: ((ay * t + by) * t + cy) * t + p1y;
|
||||
} else {
|
||||
// type === 1: getTangent()
|
||||
// type === 2: getNormal()
|
||||
|
|
|
@ -37,6 +37,16 @@ test('Curve#getPointAtTime()', function() {
|
|||
|
||||
equals(curve.getPointAt(curve.length + 1), null,
|
||||
'Should return null when offset is out of range.');
|
||||
|
||||
// #960:
|
||||
var curve = new Curve({
|
||||
segment1: [178.58559999999994, 333.41440000000006],
|
||||
segment2: [178.58559999999994, 178.58560000000008]
|
||||
});
|
||||
equals(curve.getPointAtTime(0).y, curve.point1.y,
|
||||
'Point at t=0 should not deviate from the actual coordinates.');
|
||||
equals(curve.getPointAtTime(1).y, curve.point2.y,
|
||||
'Point at t=1 should not deviate from the actual coordinates.');
|
||||
});
|
||||
|
||||
test('Curve#getTangentAtTime()', function() {
|
||||
|
|
Loading…
Reference in a new issue