define(["Ti/_/declare","Ti/_/Evented","Ti/_/lang","Ti/Platform"],function(t,i,n,r){function o(t,i,n){var r=0==i?1:0,o=2==i?1:2,a=0==t?1:0,e=2==t?1:2;return n[a][r]*n[e][o]-n[a][o]*n[e][r]}function a(t,i,n,r,o,a,e,s){return{a:t.a*i+t.b*r,b:t.a*n+t.b*o,c:t.c*i+t.d*r,d:t.c*n+t.d*o,tx:t.a*a+t.b*e+t.tx,ty:t.c*a+t.d*e+t.ty,rotation:t.rotation+(0|s)}}var e,s="gecko"===r.runtime,h=function(t){return s?t+"px":t};return e=t("Ti.UI.2DMatrix",i,{properties:{a:1,b:0,c:0,d:1,tx:0,ty:0,rotation:0},constructor:function(t){t&&require.mix(this,t)},invert:function(){var t=0,i=0,n=[[this.a,this.b,this.tx],[this.c,this.d,this.ty],[0,0,1]],r=n,s=this.a*o(0,0,n)-this.b*o(0,1,n)+this.tx*o(0,2,n);if(Math.abs(s)>1e-10)for(s=1/s;3>i;i++)for(;3>t;t++)r[i][t]=o(t,i,n)*s,(t+i)%2==1&&(r[i][t]=-r[i][t]);return new e(a(this,r[0][0],r[0][1],r[1][0],r[1][1],r[0][2],r[1][2]))},multiply:function(t){return new e(a(this,t.a,t.b,t.c,t.d,t.tx,t.ty,t.rotation))},rotate:function(t){return new e({a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty,rotation:this.rotation+t})},scale:function(t,i){return new e(a(this,t,0,0,n.val(i,t),0,0))},translate:function(t,i){return new e(a(this,1,0,0,1,t,i))},toCSS:function(){for(var t=0,i=[this.a,this.b,this.c,this.d,this.tx,this.ty];6>t;t++)i[t]=i[t].toFixed(6),t>4&&(i[t]=h(i[t]));return"matrix("+i.join(",")+") rotate("+this.rotation+"deg)"}})});