Shorten #_transformCoordinates() a bit.

This commit is contained in:
Jürg Lehni 2011-05-02 08:59:51 +01:00
parent 26b70309a8
commit 98ab342235

View file

@ -250,47 +250,47 @@ var Segment = this.Segment = Base.extend({
handleIn = matrix && this.getHandleInIfSet() || this._handleIn, handleIn = matrix && this.getHandleInIfSet() || this._handleIn,
handleOut = matrix && this.getHandleOutIfSet() || this._handleOut, handleOut = matrix && this.getHandleOutIfSet() || this._handleOut,
x = point._x, x = point._x,
y = point._y; y = point._y,
i = 2;
coords[0] = x; coords[0] = x;
coords[1] = y; coords[1] = y;
var index = 2;
// We need to convert handles to absolute coordinates in order // We need to convert handles to absolute coordinates in order
// to transform them. // to transform them.
if (handleIn) { if (handleIn) {
coords[index++] = handleIn._x + x; coords[i++] = handleIn._x + x;
coords[index++] = handleIn._y + y; coords[i++] = handleIn._y + y;
} }
if (handleOut) { if (handleOut) {
coords[index++] = handleOut._x + x; coords[i++] = handleOut._x + x;
coords[index++] = handleOut._y + y; coords[i++] = handleOut._y + y;
} }
if (matrix) { if (matrix) {
matrix.transform(coords, 0, coords, 0, index / 2); matrix.transform(coords, 0, coords, 0, i / 2);
x = coords[0]; x = coords[0];
y = coords[1]; y = coords[1];
if (change) { if (change) {
// If change is true, we need to set the new values back // If change is true, we need to set the new values back
point._x = x; point._x = x;
point._y = y; point._y = y;
index = 2; i = 2;
if (handleIn) { if (handleIn) {
handleIn._x = coords[index++] - x; handleIn._x = coords[i++] - x;
handleIn._y = coords[index++] - y; handleIn._y = coords[i++] - y;
} }
if (handleOut) { if (handleOut) {
handleOut._x = coords[index++] - x; handleOut._x = coords[i++] - x;
handleOut._y = coords[index++] - y; handleOut._y = coords[i++] - y;
} }
} else { } else {
// We want to receive the results in coords, so make sure // We want to receive the results in coords, so make sure
// handleIn and out are defined too, even if they're 0 // handleIn and out are defined too, even if they're 0
if (!handleIn) { if (!handleIn) {
coords[index++] = x; coords[i++] = x;
coords[index++] = y; coords[i++] = y;
} }
if (!handleOut) { if (!handleOut) {
coords[index++] = x; coords[i++] = x;
coords[index++] = y; coords[i++] = y;
} }
} }
} }