Skip to content

Commit

Permalink
added a matrix property to all shapes for advanced transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonobr1 committed May 14, 2013
1 parent f96ca5d commit 75a946a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 33 deletions.
22 changes: 14 additions & 8 deletions build/two.clean.js
Expand Up @@ -1210,7 +1210,7 @@
},
set: function(v) {
x = v;
this.trigger('change', 'x');
this.trigger(Two.Events.change, 'x');
}
});

Expand All @@ -1220,7 +1220,7 @@
},
set: function(v) {
y = v;
this.trigger('change', 'y');
this.trigger(Two.Events.change, 'y');
}
});

Expand Down Expand Up @@ -1440,7 +1440,7 @@

});

_.extend(Matrix.prototype, {
_.extend(Matrix.prototype, Backbone.Events, {

/**
* Takes an array of elements or the arguments list itself to
Expand All @@ -1460,7 +1460,7 @@
}
}, this);

return this;
return this.trigger(Two.Events.change);

},

Expand Down Expand Up @@ -1490,7 +1490,7 @@
this.elements[i] = v * a;
}, this);

return this;
return this.trigger(Two.Events.change);

}

Expand Down Expand Up @@ -1536,7 +1536,7 @@
this.elements[7] = A6 * B1 + A7 * B4 + A8 * B7;
this.elements[8] = A6 * B2 + A7 * B5 + A8 * B8;

return this;
return this.trigger(Two.Events.change);

},

Expand Down Expand Up @@ -3215,11 +3215,12 @@
.identity()
.translate(this.translation.x, this.translation.y)
.scale(this.scale)
.rotate(this.rotation);
.rotate(this.rotation)
.multiply.apply(this._matrix, this.matrix.elements);
this.trigger(Two.Events.change, this.id, 'matrix', transform, this.scale);
}, this), 0);

this._rotation = 'rotation';
this._rotation = 0;

Object.defineProperty(this, 'rotation', {
get: function() {
Expand Down Expand Up @@ -3249,6 +3250,11 @@

this.translation.bind(Two.Events.change, updateMatrix);

// Add a public matrix for advanced transformations.
// Only edit this if you're a *boss*
this.matrix = new Two.Matrix();
this.matrix.bind(Two.Events.change, updateMatrix);

if (!!limited) {
return this;
}
Expand Down
22 changes: 14 additions & 8 deletions build/two.js
Expand Up @@ -2426,7 +2426,7 @@ var Backbone = Backbone || {};
},
set: function(v) {
x = v;
this.trigger('change', 'x');
this.trigger(Two.Events.change, 'x');
}
});

Expand All @@ -2436,7 +2436,7 @@ var Backbone = Backbone || {};
},
set: function(v) {
y = v;
this.trigger('change', 'y');
this.trigger(Two.Events.change, 'y');
}
});

Expand Down Expand Up @@ -2656,7 +2656,7 @@ var Backbone = Backbone || {};

});

_.extend(Matrix.prototype, {
_.extend(Matrix.prototype, Backbone.Events, {

/**
* Takes an array of elements or the arguments list itself to
Expand All @@ -2676,7 +2676,7 @@ var Backbone = Backbone || {};
}
}, this);

return this;
return this.trigger(Two.Events.change);

},

Expand Down Expand Up @@ -2706,7 +2706,7 @@ var Backbone = Backbone || {};
this.elements[i] = v * a;
}, this);

return this;
return this.trigger(Two.Events.change);

}

Expand Down Expand Up @@ -2752,7 +2752,7 @@ var Backbone = Backbone || {};
this.elements[7] = A6 * B1 + A7 * B4 + A8 * B7;
this.elements[8] = A6 * B2 + A7 * B5 + A8 * B8;

return this;
return this.trigger(Two.Events.change);

},

Expand Down Expand Up @@ -4431,11 +4431,12 @@ var Backbone = Backbone || {};
.identity()
.translate(this.translation.x, this.translation.y)
.scale(this.scale)
.rotate(this.rotation);
.rotate(this.rotation)
.multiply.apply(this._matrix, this.matrix.elements);
this.trigger(Two.Events.change, this.id, 'matrix', transform, this.scale);
}, this), 0);

this._rotation = 'rotation';
this._rotation = 0;

Object.defineProperty(this, 'rotation', {
get: function() {
Expand Down Expand Up @@ -4465,6 +4466,11 @@ var Backbone = Backbone || {};

this.translation.bind(Two.Events.change, updateMatrix);

// Add a public matrix for advanced transformations.
// Only edit this if you're a *boss*
this.matrix = new Two.Matrix();
this.matrix.bind(Two.Events.change, updateMatrix);

if (!!limited) {
return this;
}
Expand Down

0 comments on commit 75a946a

Please sign in to comment.