mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Use variable definition chaining in Matrix where possible.
This commit is contained in:
parent
32d0f31c31
commit
a7d08bcc08
1 changed files with 11 additions and 10 deletions
|
@ -263,8 +263,8 @@ var Matrix = this.Matrix = Base.extend({
|
||||||
* @return {Matrix} This affine transform.
|
* @return {Matrix} This affine transform.
|
||||||
*/
|
*/
|
||||||
concatenate: function(mx) {
|
concatenate: function(mx) {
|
||||||
var m0 = this._m00;
|
var m0 = this._m00,
|
||||||
var m1 = this._m01;
|
m1 = this._m01;
|
||||||
this._m00 = mx._m00 * m0 + mx._m10 * m1;
|
this._m00 = mx._m00 * m0 + mx._m10 * m1;
|
||||||
this._m01 = mx._m01 * m0 + mx._m11 * m1;
|
this._m01 = mx._m01 * m0 + mx._m11 * m1;
|
||||||
this._m02 += mx._m02 * m0 + mx._m12 * m1;
|
this._m02 += mx._m02 * m0 + mx._m12 * m1;
|
||||||
|
@ -284,8 +284,8 @@ var Matrix = this.Matrix = Base.extend({
|
||||||
* @return {Matrix} This affine transform.
|
* @return {Matrix} This affine transform.
|
||||||
*/
|
*/
|
||||||
preConcatenate: function(mx) {
|
preConcatenate: function(mx) {
|
||||||
var m0 = this._m00;
|
var m0 = this._m00,
|
||||||
var m1 = this._m10;
|
m1 = this._m10;
|
||||||
this._m00 = mx._m00 * m0 + mx._m01 * m1;
|
this._m00 = mx._m00 * m0 + mx._m01 * m1;
|
||||||
this._m10 = mx._m10 * m0 + mx._m11 * m1;
|
this._m10 = mx._m10 * m0 + mx._m11 * m1;
|
||||||
|
|
||||||
|
@ -319,9 +319,9 @@ var Matrix = this.Matrix = Base.extend({
|
||||||
*/
|
*/
|
||||||
transform: function(/* point | */ src, srcOff, dst, dstOff, numPts) {
|
transform: function(/* point | */ src, srcOff, dst, dstOff, numPts) {
|
||||||
if (arguments.length == 5) {
|
if (arguments.length == 5) {
|
||||||
var i = srcOff;
|
var i = srcOff,
|
||||||
var j = dstOff;
|
j = dstOff,
|
||||||
var srcEnd = srcOff + 2 * numPts;
|
srcEnd = srcOff + 2 * numPts;
|
||||||
while (i < srcEnd) {
|
while (i < srcEnd) {
|
||||||
var x = src[i++];
|
var x = src[i++];
|
||||||
var y = src[i++];
|
var y = src[i++];
|
||||||
|
@ -470,9 +470,10 @@ var Matrix = this.Matrix = Base.extend({
|
||||||
center = Point.read(arguments, 1);
|
center = Point.read(arguments, 1);
|
||||||
if (center) {
|
if (center) {
|
||||||
angle = angle * Math.PI / 180.0;
|
angle = angle * Math.PI / 180.0;
|
||||||
var x = center.x, y = center.y;
|
var x = center.x,
|
||||||
var cos = Math.cos(angle);
|
y = center.y,
|
||||||
var sin = Math.sin(angle);
|
cos = Math.cos(angle),
|
||||||
|
sin = Math.sin(angle);
|
||||||
this.set(cos, sin, -sin, cos,
|
this.set(cos, sin, -sin, cos,
|
||||||
x - x * cos + y * sin,
|
x - x * cos + y * sin,
|
||||||
y - x * sin - y * cos);
|
y - x * sin - y * cos);
|
||||||
|
|
Loading…
Reference in a new issue