Fix bug in Segment#_transformCoordinates, where handles were not set when they were zero, change was false and no matrix was provided.

This commit is contained in:
Jürg Lehni 2011-07-02 06:24:27 +02:00
parent 7e26a7af1e
commit 3eecb924c8

View file

@ -332,13 +332,15 @@ var Segment = this.Segment = Base.extend(/** @lends Segment# */{
// points for largely improved performance, as no calls to // points for largely improved performance, as no calls to
// Point.read() and Point constructors are necessary. // Point.read() and Point constructors are necessary.
var point = this._point, var point = this._point,
// If a matrix is defined, only transform handles if they are set. // If change is true, only transform handles if they are set, as
// This saves some computation time. If no matrix is set, always // _transformCoordinates is called only to change the segment, no
// to receive the coords.
// This saves some computation time. If change is false, always
// use the real handles, as we just want to receive a filled // use the real handles, as we just want to receive a filled
// coords array for getBounds(). // coords array for getBounds().
handleIn = !matrix || !this._handleIn.isZero() handleIn = !change || !this._handleIn.isZero()
? this._handleIn : null, ? this._handleIn : null,
handleOut = !matrix || !this._handleOut.isZero() handleOut = !change || !this._handleOut.isZero()
? this._handleOut : null, ? this._handleOut : null,
x = point._x, x = point._x,
y = point._y, y = point._y,
@ -355,34 +357,36 @@ var Segment = this.Segment = Base.extend(/** @lends Segment# */{
coords[i++] = handleOut._x + x; coords[i++] = handleOut._x + x;
coords[i++] = handleOut._y + y; coords[i++] = handleOut._y + y;
} }
if (matrix) { // If no matrix was previded, this was just called to get the coords and
matrix._transformCoordinates(coords, 0, coords, 0, i / 2); // we are done now.
x = coords[0]; if (!matrix)
y = coords[1]; return;
if (change) { matrix._transformCoordinates(coords, 0, coords, 0, i / 2);
// If change is true, we need to set the new values back x = coords[0];
point._x = x; y = coords[1];
point._y = y; if (change) {
i = 2; // If change is true, we need to set the new values back
if (handleIn) { point._x = x;
handleIn._x = coords[i++] - x; point._y = y;
handleIn._y = coords[i++] - y; i = 2;
} if (handleIn) {
if (handleOut) { handleIn._x = coords[i++] - x;
handleOut._x = coords[i++] - x; handleIn._y = coords[i++] - y;
handleOut._y = coords[i++] - y; }
} if (handleOut) {
} else { handleOut._x = coords[i++] - x;
// We want to receive the results in coords, so make sure handleOut._y = coords[i++] - y;
// handleIn and out are defined too, even if they're 0 }
if (!handleIn) { } else {
coords[i++] = x; // We want to receive the results in coords, so make sure
coords[i++] = y; // handleIn and out are defined too, even if they're 0
} if (!handleIn) {
if (!handleOut) { coords[i++] = x;
coords[i++] = x; coords[i++] = y;
coords[i++] = y; }
} if (!handleOut) {
coords[i++] = x;
coords[i++] = y;
} }
} }
} }