kopia lustrzana https://github.com/c9/core
4 wiersze
15 KiB
JavaScript
4 wiersze
15 KiB
JavaScript
![]() |
define(function(require, exports, module) {
|
||
|
FirminCSSMatrix=function(c){this.m11=this.m22=this.m33=this.m44=1;this.m12=this.m13=this.m14=this.m21=this.m23=this.m24=this.m31=this.m32=this.m34=this.m41=this.m42=this.m43=0;if(typeof c=="string"){this.setMatrixValue(c)}};FirminCSSMatrix.displayName="FirminCSSMatrix";FirminCSSMatrix.degreesToRadians=function(c){return c*Math.PI/180};FirminCSSMatrix.determinant2x2=function(c,b,a,d){return c*d-b*a};FirminCSSMatrix.determinant3x3=function(c,b,a,d,e,j,f,g,h){var i=FirminCSSMatrix.determinant2x2;return c*i(e,j,g,h)-d*i(b,a,g,h)+f*i(b,a,e,j)};FirminCSSMatrix.determinant4x4=function(c){var b=FirminCSSMatrix.determinant3x3,a=c.m11,d=c.m21,e=c.m31,j=c.m41,f=c.m12,g=c.m22,h=c.m32,i=c.m42,k=c.m13,l=c.m23,m=c.m33,n=c.m43,o=c.m14,p=c.m24,q=c.m34,r=c.m44;return a*b(g,l,p,h,m,q,i,n,r)-d*b(f,k,o,h,m,q,i,n,r)+e*b(f,k,o,g,l,p,i,n,r)-j*b(f,k,o,g,l,p,h,m,q)};[["m11","a"],["m12","b"],["m21","c"],["m22","d"],["m41","e"],["m42","f"]].forEach(function(b){var a=b[0],d=b[1];Object.defineProperty(FirminCSSMatrix.prototype,d,{set:function(c){this[a]=c},get:function(){return this[a]}})});FirminCSSMatrix.prototype.isAffine=function(){return this.m13===0&&this.m14===0&&this.m23===0&&this.m24===0&&this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m43===0&&this.m44===1};FirminCSSMatrix.prototype.multiply=function(c){var b=this,a=c,d=new FirminCSSMatrix();d.m11=b.m11*a.m11+b.m12*a.m21+b.m13*a.m31+b.m14*a.m41;d.m12=b.m11*a.m12+b.m12*a.m22+b.m13*a.m32+b.m14*a.m42;d.m13=b.m11*a.m13+b.m12*a.m23+b.m13*a.m33+b.m14*a.m43;d.m14=b.m11*a.m14+b.m12*a.m24+b.m13*a.m34+b.m14*a.m44;d.m21=b.m21*a.m11+b.m22*a.m21+b.m23*a.m31+b.m24*a.m41;d.m22=b.m21*a.m12+b.m22*a.m22+b.m23*a.m32+b.m24*a.m42;d.m23=b.m21*a.m13+b.m22*a.m23+b.m23*a.m33+b.m24*a.m43;d.m24=b.m21*a.m14+b.m22*a.m24+b.m23*a.m34+b.m24*a.m44;d.m31=b.m31*a.m11+b.m32*a.m21+b.m33*a.m31+b.m34*a.m41;d.m32=b.m31*a.m12+b.m32*a.m22+b.m33*a.m32+b.m34*a.m42;d.m33=b.m31*a.m13+b.m32*a.m23+b.m33*a.m33+b.m34*a.m43;d.m34=b.m31*a.m14+b.m32*a.m24+b.m33*a.m34+b.m34*a.m44;d.m41=b.m41*a.m11+b.m42*a.m21+b.m43*a.m31+b.m44*a.m41;d.m42=b.m41*a.m12+b.m42*a.m22+b.m43*a.m32+b.m44*a.m42;d.m43=b.m41*a.m13+b.m42*a.m23+b.m43*a.m33+b.m44*a.m43;d.m44=b.m41*a.m14+b.m42*a.m24+b.m43*a.m34+b.m44*a.m44;return d};FirminCSSMatrix.prototype.isIdentityOrTranslation=function(){var c=this;return c.m11===1&&c.m12===0&&c.m13===0&&c.m14===0&&c.m21===0&&c.m22===1&&c.m23===0&&c.m24===0&&c.m31===0&&c.m31===0&&c.m33===1&&c.m34===0&&c.m44===1};FirminCSSMatrix.prototype.adjoint=function(){var c=new FirminCSSMatrix(),b=this,a=FirminCSSMatrix.determinant3x3,d=b.m11,e=b.m12,j=b.m13,f=b.m14,g=b.m21,h=b.m22,i=b.m23,k=b.m24,l=b.m31,m=b.m32,n=b.m33,o=b.m34,p=b.m41,q=b.m42,r=b.m43,s=b.m44;c.m11=a(h,m,q,i,n,r,k,o,s);c.m21=-a(g,l,p,i,n,r,k,o,s);c.m31=a(g,l,p,h,m,q,k,o,s);c.m41=-a(g,l,p,h,m,q,i,n,r);c.m12=-a(e,m,q,j,n,r,f,o,s);c.m22=a(d,l,p,j,n,r,f,o,s);c.m32=-a(d,l,p,e,m,q,f,o,s);c.m42=a(d,l,p,e,m,q,j,n,r);c.m13=a(e,h,q,j,i,r,f,k,s);c.m23=-a(d,g,p,j,i,r,f,k,s);c.m33=a(d,g,p,e,h,q,f,k,s);c.m43=-a(d,g,p,e,h,q,j,i,r);c.m14=-a(e,h,m,j,i,n,f,k,o);c.m24=a(d,g,l,j,i,n,f,k,o);c.m34=-a(d,g,l,e,h,m,f,k,o);c.m44=a(d,g,l,e,h,m,j,i,n);return c};FirminCSSMatrix.prototype.inverse=function(){var c,b,a,d,e;if(this.isIdentityOrTranslation()){c=new FirminCSSMatrix();if(!(this.m41===0&&this.m42===0&&this.m43===0)){c.m41=-this.m41;c.m42=-this.m42;c.m43=-this.m43}return c}a=this.adjoint();b=FirminCSSMatrix.determinant4x4(this);if(Math.abs(b)<1e-8)return null;for(d=1;d<5;d++){for(e=1;e<5;e++){a[("m"+d)+e]/=b}}return a};FirminCSSMatrix.prototype.rotate=function(c,b,a){var d=FirminCSSMatrix.degreesToRadians;if(typeof c!="number"||isNaN(c))c=0;if((typeof b!="number"||isNaN(b))&&(typeof a!="number"||isNaN(a))){a=c;c=0;b=0}if(typeof b!="number"||isNaN(b))b=0;if(typeof a!="number"||isNaN(a))a=0;c=d(c);b=d(b);a=d(a);var e=new FirminCSSMatrix(),j=new FirminCSSMatrix(),f=new FirminCSSMatrix(),g,h,i;a/=2;g=Math.sin(a);h=Math.cos(a);i=g*g;f.m11=f.m22=1-2*i;f.m12=f.m21=2*g*h;f.m21*=-1;b/=2;g=Math.sin(b);h=Math.cos(b);i=g*g;j.m11=j.m33=1-2*i;j.m13=j.m31=2*g*h;j.m13*=-1;c/=2;g=Math.sin(c);h=Math.cos(c
|
||
|
Firmin=(typeof Firmin=='undefined')?{}:Firmin;Firmin.CSSMatrix=(typeof WebKitCSSMatrix=='object')?WebKitCSSMatrix:FirminCSSMatrix;Firmin.prefix=(function(){var a=document.createElement("div"),b=["webkit","Moz","O"],c=3,d;while(c--){d=b[c];a.style.cssText="-"+d.toLowerCase()+"-transition-property:opacity;";if(typeof a.style[d+"TransitionProperty"]!="undefined")return d}return d})();Firmin.matrixToString=function(d){if(Firmin.prefix!="Moz")return d.toString();var e="matrix(",f=["a","b","c","d","e","f"];return e+f.map(function(a,b){var c=d[a].toFixed(6);if(b>3)c+="px";return c}).join(", ")+")"};Firmin.angleToRadians=function(a,b){var c;switch(a){case"rad":return b;case"deg":c=Math.PI/180;break;case"grad":c=Math.PI/200;break;case"turn":c=Math.PI*2;break}return c*b};Firmin.pointToVector=function(a){if(!a)return null;return a instanceof Array?a:[a.x,a.y,a.z]};Firmin.NUMBER_PATTERN=/^-?\d+(\.\d+)?/;Firmin.parseNumeric=function(e,f){return function(b){var c,d;if(typeof b=="number"){return[f,b]}else if(typeof b!="string"){return null}d=(b.match(Firmin.NUMBER_PATTERN)||[""])[0];if(d.length===b.length){c=f}else{c=e.filter(function(a){return b.substr(d.length)===a})[0]}return c&&d?[c,parseFloat(d)]:null}};Firmin.parseAngle=Firmin.parseNumeric(["deg","grad","rad","turn"],"deg");Firmin.parseTime=Firmin.parseNumeric(["s","ms"],"s");Firmin.Transform=function(a,b){this.ctm=a||new Firmin.CSSMatrix();this.centre=Firmin.pointToVector(b)||["50%","50%",0]};Firmin.Transform.methods=["translate","translate3d","translateX","translateY","translateZ","scale","scale3d","scaleX","scaleY","scaleZ","rotate","rotate3d","rotateX","rotateY","rotateZ","skew","skewX","skewY","matrix","matrix3d"];Firmin.Transform.parse=function(a,b){var c=Firmin.Transform.methods,d={},e=null,f,g;if(typeof b==="object"&&b.transform){f=b.transform.ctm;g=b.transform.centre;e=new Firmin.Transform(f,g)}for(property in a){if(c.indexOf(property)!==-1){e=e||new Firmin.Transform();e[property](a[property])}else if(property==="origin"){e=e||new Firmin.Transform();e[property](a[property])}else{d[property]=a[property]}}return{result:e,remainder:d}};Firmin.Transform.prototype.build=function(a){var b=this.centre;if(Firmin.prefix=="O"){b=b.slice(0,2)}a=a||{};a[Firmin.prefix+"Transform"]=Firmin.matrixToString(this.ctm);a[Firmin.prefix+"TransformOrigin"]=b.join(" ");return a};Firmin.Transform.prototype.matrix=Firmin.Transform.prototype.matrix3d=function(a){var b=new Firmin.CSSMatrix();if(a.length===6){b.a=a[0];b.b=a[1];b.c=a[2];b.d=a[3];b.e=a[4];b.f=a[5]}else{b.m11=a[0];b.m12=a[1];b.m13=a[2];b.m14=a[3];b.m21=a[4];b.m22=a[5];b.m23=a[6];b.m24=a[7];b.m31=a[8];b.m32=a[9];b.m33=a[10];b.m34=a[11];b.m41=a[12];b.m42=a[13];b.m43=a[14];b.m44=a[15]}this.ctm=this.ctm.multiply(b)};Firmin.Transform.prototype.translate=Firmin.Transform.prototype.translate3d=function(a){var b,c,d,e;if(typeof a=="number"||typeof a=="string"){c=d=parseInt(a,10)||0;e=0}else{b=Firmin.pointToVector(a);c=b[0];d=b[1];e=b[2];if(typeof c!="number")c=parseInt(c,10)||0;if(typeof d!="number")d=parseInt(d,10)||0;if(typeof e!="number")e=parseInt(e,10)||0}this.ctm=this.ctm.translate(c,d,e)};Firmin.Transform.prototype.translateX=function(a){this.translate([a,0])};Firmin.Transform.prototype.translateY=function(a){this.translate([0,a])};Firmin.Transform.prototype.translateZ=function(a){this.translate3d([0,0,a])};Firmin.Transform.prototype.scale=Firmin.Transform.prototype.scale3d=function(a){var b,c,d,e;if(typeof a=="number"){c=d=a;e=1}else{b=Firmin.pointToVector(a);c=b[0];d=b[1];e=b[2]}this.ctm=this.ctm.scale(c,d,e)};Firmin.Transform.prototype.scaleX=function(a){this.scale3d([a,1,1])};Firmin.Transform.prototype.scaleY=function(a){this.scale3d([1,a,1])};Firmin.Transform.prototype.scaleZ=function(a){this.scale3d([1,1,a])};Firmin.Transform.prototype.skew=function(a){var b=Firmin.parseAngle,c=Firmin.angleToRadians,d,e;if(typeof a=="number"||typeof a=="string"){d=e=c.apply(null,b(a))||0}else{a=Firmin.pointToVector(a);d=c.apply(null,b(a[0]))||0;e=c.apply(null,b(a[1]))||0}this.matrix([1,Math.tan(e),Math.tan(d),1,0,0])};Firmin.Transform.prototype.s
|
||
|
});
|