1 define([ ], function () {
2 function Transform(options) {
9 'x,y,scaleX,scaleY,rotation'.split(',').forEach(function (prop) {
10 if (prop in options) {
11 this[prop] = options[prop];
15 // Matrix <=> array index representation:
19 var cos = Math.cos(this.rotation);
20 var sin = Math.sin(this.rotation);
22 cos * this.scaleX, -sin, this.x,
23 sin, cos * this.scaleY, this.y,
24 0, 0, 0 // Padding to pass as 3fv to WebGL
27 this.cssTransform2d = '' +
28 'translate(' + this.x + 'px,' + this.y + 'px) ' +
29 'scale(' + this.scaleX + ',' + this.scaleY + ') ' +
30 'rotate(' + this.rotation + 'rad) ' +
33 this.cssTransform3d = '' +
34 'translate3D(' + this.x + 'px,' + this.y + 'px,0px) ' +
35 'scale3D(' + this.scaleX + ',' + this.scaleY + ',1) ' +
36 'rotate(' + this.rotation + 'rad) ' +
40 Transform.prototype.transformPointInto = function transformPointInto(x, y, out, offset) {
42 out[offset + 0] = m[0] * x + m[3] * y + m[2];
43 out[offset + 1] = m[1] * x + m[4] * y + m[5];