Skip to content

Commit

Permalink
fixing some typos that made matrices animate incorrectly.
Browse files Browse the repository at this point in the history
  • Loading branch information
heygrady committed Dec 4, 2010
1 parent 2139fd8 commit 22c2727
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 150 deletions.
89 changes: 47 additions & 42 deletions dist/jquery.transform-0.9.1.js → dist/jquery.transform-0.9.2.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*!
* jQuery 2d Transform v0.9.1
* jQuery 2d Transform v0.9.2
* http://wiki.github.com/heygrady/transform/
*
* Copyright 2010, Grady Kuhnline
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Date: Fri Nov 26 23:43:06 2010 -0800
* Date: Mon Nov 29 22:56:20 2010 -0800
*/
///////////////////////////////////////////////////////
// Transform
Expand Down Expand Up @@ -136,7 +136,7 @@
t.exec(funcs, options);
}
});
};
};

$.transform.prototype = {
/**
Expand Down Expand Up @@ -810,7 +810,7 @@
// Store the original values onto the optall
optall.original[name] = val.toString();

// reduce to a unitless number
// reduce to a unitless number (to trick animate)
prop[name] = parseFloat(val);
}
} );
Expand Down Expand Up @@ -972,23 +972,24 @@

// skip functions that won't affect the transform
if (((k === 'scaleX' || k === 'scaleY') && d.now[k] === 1) ||
((k !== 'scaleX' || k !== 'scaleY') && d.now[k] === 0)) {
(k !== 'scaleX' && k !== 'scaleY' && d.now[k] === 0)) {
return true;
}

// calculating
m = m.x($m[k](d.now[k]));
});
// save the correct matrix values for now

// save the correct matrix values for the value of now
var val;
$.each(fx.values, function(i) {
switch (i) {
case 0: val = parseFloat(m.e(1, 1).toFixed(6)); break;
case 1: val = parseFloat(m.e(1, 2).toFixed(6)); break;
case 2: val = parseFloat(m.e(2, 1).toFixed(6)); break;
case 1: val = parseFloat(m.e(2, 1).toFixed(6)); break;
case 2: val = parseFloat(m.e(1, 2).toFixed(6)); break;
case 3: val = parseFloat(m.e(2, 2).toFixed(6)); break;
case 4: val = parseFloat(m.e(3, 1).toFixed(6)); break;
case 5: val = parseFloat(m.e(3, 2).toFixed(6)); break;
case 4: val = parseFloat(m.e(1, 3).toFixed(6)); break;
case 5: val = parseFloat(m.e(2, 3).toFixed(6)); break;
}
fx.values[i].now = val;
});
Expand Down Expand Up @@ -1205,8 +1206,9 @@
matrix: {}
});
}
var $m = $.matrix;

$.extend( $.matrix, {
$.extend( $m, {
/**
* A 2-value vector
* @param Number x
Expand Down Expand Up @@ -1298,8 +1300,8 @@
b = this.e(2, 1),
c = this.e(1, 2),
d = this.e(2, 2),
e = this.e(3, 1),
f = this.e(3, 2);
e = this.e(1, 3),
f = this.e(2, 3);

// In case the matrix can't be decomposed
if (Math.abs(a * d - b * c) < 0.01) {
Expand Down Expand Up @@ -1359,10 +1361,10 @@
};

/** Extend all of the matrix types with the same prototype */
$.extend($.matrix.M2x2.prototype, Matrix, {
$.extend($m.M2x2.prototype, Matrix, {
toM3x3: function() {
var a = this.elements;
return new $.matrix.M3x3(
return new $m.M3x3(
a[0], a[1], 0,
a[2], a[3], 0,
0, 0, 1
Expand All @@ -1387,13 +1389,13 @@

if (isVector && b.length == 2) {
// b is actually a vector
return new $.matrix.V2(
return new $m.V2(
a[0] * b[0] + a[1] * b[1],
a[2] * b[0] + a[3] * b[1]
);
} else if (b.length == a.length) {
// b is a 2x2 matrix
return new $.matrix.M2x2(
return new $m.M2x2(
a[0] * b[0] + a[1] * b[2],
a[0] * b[1] + a[1] * b[3],

Expand All @@ -1413,7 +1415,7 @@
inverse: function() {
var d = 1/this.determinant(),
a = this.elements;
return new $.matrix.M2x2(
return new $m.M2x2(
d * a[3], d * -a[1],
d * -a[2], d * a[0]
);
Expand All @@ -1431,7 +1433,7 @@
}
});

$.extend($.matrix.M3x3.prototype, Matrix, {
$.extend($m.M3x3.prototype, Matrix, {
/**
* Multiply a 3x3 matrix by a similar matrix or a vector
* @param M3x3 | V3 matrix
Expand All @@ -1450,14 +1452,14 @@

if (isVector && b.length == 3) {
// b is actually a vector
return new $.matrix.V3(
return new $m.V3(
a[0] * b[0] + a[1] * b[1] + a[2] * b[2],
a[3] * b[0] + a[4] * b[1] + a[5] * b[2],
a[6] * b[0] + a[7] * b[1] + a[8] * b[2]
);
} else if (b.length == a.length) {
// b is a 3x3 matrix
return new $.matrix.M3x3(
return new $m.M3x3(
a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
Expand All @@ -1483,7 +1485,7 @@
inverse: function() {
var d = 1/this.determinant(),
a = this.elements;
return new $.matrix.M3x3(
return new $m.M3x3(
d * ( a[8] * a[4] - a[7] * a[5]),
d * (-(a[8] * a[1] - a[7] * a[2])),
d * ( a[5] * a[1] - a[4] * a[2]),
Expand Down Expand Up @@ -1523,8 +1525,8 @@
};

/** Extend all of the vector types with the same prototype */
$.extend($.matrix.V2.prototype, Vector);
$.extend($.matrix.V3.prototype, Vector);
$.extend($m.V2.prototype, Vector);
$.extend($m.V3.prototype, Vector);
})(jQuery, this, this.document);
///////////////////////////////////////////////////////
// Matrix Calculations
Expand Down Expand Up @@ -1731,8 +1733,11 @@
matrix: {}
});
}
var $m = $.matrix,
$m2x2 = $m.M2x2,
$m3x3 = $m.M3x3;

$.extend( $.matrix, {
$.extend( $m, {
/**
* Identity matrix
* @param Number size
Expand All @@ -1746,7 +1751,7 @@
for (var i = 0; i < length; i++) {
elements[i] = (i % mod) === 0 ? 1 : 0;
}
return new $.matrix['M'+size+'x'+size](elements);
return new $m['M'+size+'x'+size](elements);
},

/**
Expand All @@ -1758,12 +1763,12 @@
// arguments are in column-major order
switch (arguments.length) {
case 4:
return new $.matrix.M2x2(
return new $m2x2(
args[0], args[2],
args[1], args[3]
);
case 6:
return new $.matrix.M3x3(
return new $m3x3(
args[0], args[2], args[4],
args[1], args[3], args[5],
0, 0, 1
Expand All @@ -1776,7 +1781,7 @@
* @return Matrix
*/
reflect: function() {
return new $.matrix.M2x2(
return new $m2x2(
-1, 0,
0, -1
);
Expand All @@ -1787,7 +1792,7 @@
* @return Matrix
*/
reflectX: function() {
return new $.matrix.M2x2(
return new $m2x2(
1, 0,
0, -1
);
Expand All @@ -1798,7 +1803,7 @@
* @return Matrix
*/
reflectXY: function() {
return new $.matrix.M2x2(
return new $m2x2(
0, 1,
1, 0
);
Expand All @@ -1809,7 +1814,7 @@
* @return Matrix
*/
reflectY: function() {
return new $.matrix.M2x2(
return new $m2x2(
-1, 0,
0, 1
);
Expand All @@ -1832,7 +1837,7 @@
c = -sintheta,
d = costheta;

return new $.matrix.M2x2(
return new $m2x2(
a, c,
b, d
);
Expand All @@ -1849,7 +1854,7 @@
sx = sx || sx === 0 ? sx : 1;
sy = sy || sy === 0 ? sy : sx;

return new $.matrix.M2x2(
return new $m2x2(
sx, 0,
0, sy
);
Expand All @@ -1861,7 +1866,7 @@
* @return Matrix
*/
scaleX: function (sx) {
return $.matrix.scale(sx, 1);
return $m.scale(sx, 1);
},

/**
Expand All @@ -1870,7 +1875,7 @@
* @return Matrix
*/
scaleY: function (sy) {
return $.matrix.scale(1, sy);
return $m.scale(1, sy);
},

/**
Expand All @@ -1889,7 +1894,7 @@
x = Math.tan(radX),
y = Math.tan(radY);

return new $.matrix.M2x2(
return new $m2x2(
1, x,
y, 1
);
Expand All @@ -1902,7 +1907,7 @@
* @link http://www.w3.org/TR/SVG/coords.html#SkewXDefined
*/
skewX: function (degX) {
return $.matrix.skew(degX);
return $m.skew(degX);
},

/**
Expand All @@ -1912,7 +1917,7 @@
* @link http://www.w3.org/TR/SVG/coords.html#SkewYDefined
*/
skewY: function (degY) {
return $.matrix.skew(0, degY);
return $m.skew(0, degY);
},

/**
Expand All @@ -1926,7 +1931,7 @@
tx = tx || 0;
ty = ty || 0;

return new $.matrix.M3x3(
return new $m3x3(
1, 0, tx,
0, 1, ty,
0, 0, 1
Expand All @@ -1940,7 +1945,7 @@
* @link http://www.w3.org/TR/SVG/coords.html#TranslationDefined
*/
translateX: function (tx) {
return $.matrix.translate(tx);
return $m.translate(tx);
},

/**
Expand All @@ -1950,7 +1955,7 @@
* @link http://www.w3.org/TR/SVG/coords.html#TranslationDefined
*/
translateY: function (ty) {
return $.matrix.translate(0, ty);
return $m.translate(0, ty);
}
});
})(jQuery, this, this.document);

Large diffs are not rendered by default.

Loading

0 comments on commit 22c2727

Please sign in to comment.