Comparing version 0.0.4-a to 0.0.4-b
/*! | ||
* DOMMatrix v0.0.4a (https://github.com/thednp/dommatrix) | ||
* DOMMatrix v0.0.4b (https://github.com/thednp/dommatrix) | ||
* Copyright 2020 © thednp | ||
@@ -4,0 +4,0 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE) |
@@ -1,2 +0,2 @@ | ||
// DOMMatrix v0.0.4a | thednp © 2020 | MIT-License | ||
// DOMMatrix v0.0.4b | thednp © 2020 | MIT-License | ||
function m(m,t,r){var n=new u;return n.m41=n.e=m,n.m42=n.f=t,n.m43=r,n}function t(m,t,r){var n=new u;m*=Math.PI/180,t*=Math.PI/180,r*=Math.PI/180;var e=Math.cos(m),i=-Math.sin(m),a=Math.cos(t),o=-Math.sin(t),s=Math.cos(r),c=-Math.sin(r);return n.m11=n.a=a*s,n.m12=n.b=-a*c,n.m13=o,n.m21=n.c=i*o*s+e*c,n.m22=n.d=e*s-i*o*c,n.m23=-i*a,n.m31=i*c-e*o*s,n.m32=i*s+e*o*c,n.m33=e*a,n}function r(m,t,r,n){n*=Math.PI/360;var e=Math.sin(n),i=Math.cos(n),a=e*e,o=Math.sqrt(m*m+t*t+r*r);0===o?(m=0,t=0,r=1):(m/=o,t/=o,r/=o);var s=m*m,c=t*t,f=r*r,l=new u;return l.m11=l.a=1-2*(c+f)*a,l.m12=l.b=2*(m*t*a+r*e*i),l.m13=2*(m*r*a-t*e*i),l.m21=l.c=2*(t*m*a-r*e*i),l.m22=l.d=1-2*(f+s)*a,l.m23=2*(t*r*a+m*e*i),l.m31=2*(r*m*a+t*e*i),l.m32=2*(r*t*a-m*e*i),l.m33=1-2*(s+c)*a,l.m14=l.m24=l.m34=0,l.m41=l.e=l.m42=l.f=l.m43=0,l.m44=1,l}function n(m,t,r){var n=new u;return n.m11=n.a=m,n.m22=n.d=t,n.m33=r,n}function e(m){m*=Math.PI/180;var t=new u;return t.m21=t.c=Math.tan(m),t}function i(m){m*=Math.PI/180;var t=new u;return t.m12=t.b=Math.tan(m),t}function a(m,t){var r=t.m11*m.m11+t.m12*m.m21+t.m13*m.m31+t.m14*m.m41,n=t.m11*m.m12+t.m12*m.m22+t.m13*m.m32+t.m14*m.m42,e=t.m11*m.m13+t.m12*m.m23+t.m13*m.m33+t.m14*m.m43,i=t.m11*m.m14+t.m12*m.m24+t.m13*m.m34+t.m14*m.m44,a=t.m21*m.m11+t.m22*m.m21+t.m23*m.m31+t.m24*m.m41,o=t.m21*m.m12+t.m22*m.m22+t.m23*m.m32+t.m24*m.m42,s=t.m21*m.m13+t.m22*m.m23+t.m23*m.m33+t.m24*m.m43,c=t.m21*m.m14+t.m22*m.m24+t.m23*m.m34+t.m24*m.m44,f=t.m31*m.m11+t.m32*m.m21+t.m33*m.m31+t.m34*m.m41,l=t.m31*m.m12+t.m32*m.m22+t.m33*m.m32+t.m34*m.m42,h=t.m31*m.m13+t.m32*m.m23+t.m33*m.m33+t.m34*m.m43,p=t.m31*m.m14+t.m32*m.m24+t.m33*m.m34+t.m34*m.m44,y=t.m41*m.m11+t.m42*m.m21+t.m43*m.m31+t.m44*m.m41,M=t.m41*m.m12+t.m42*m.m22+t.m43*m.m32+t.m44*m.m42,x=t.m41*m.m13+t.m42*m.m23+t.m43*m.m33+t.m44*m.m43,g=t.m41*m.m14+t.m42*m.m24+t.m43*m.m34+t.m44*m.m44;return new u([r,a,f,y,n,o,l,M,e,s,h,x,i,c,p,g])}function o(m,t){var r=Array.from(t);return 16==r.length?(m.m11=m.a=r[0],m.m21=m.c=r[1],m.m31=r[2],m.m41=m.e=r[3],m.m12=m.b=r[4],m.m22=m.d=r[5],m.m32=r[6],m.m42=m.f=r[7],m.m13=r[8],m.m23=r[9],m.m33=r[10],m.m43=r[11],m.m14=r[12],m.m24=r[13],m.m34=r[14],m.m44=r[15]):6==r.length?(m.m11=m.a=r[0],m.m12=m.b=r[1],m.m14=m.e=r[4],m.m21=m.c=r[2],m.m22=m.d=r[3],m.m24=m.f=r[5]):console.error("CSSMatrix: expecting a 6/16 values Array"),m}var u=function(){for(var m=[],t=arguments.length;t--;)m[t]=arguments[t];return this.setIdentity(),m&&m.length&&this.setMatrixValue(m)},s={isIdentity:{configurable:!0},is2D:{configurable:!0}};u.prototype.setMatrixValue=function(m){var t=this;if(!m||!m.length)return t;if(m.length&&"string"==typeof m[0]&&m[0].length){var r,n,e=String(m[0]).trim();if("none"==e)return t;r=e.slice(0,e.indexOf("(")),n=e.slice("matrix"===r?7:9,-1).split(",").map((function(m){return Math.abs(m)<1e-6?0:+m})),[6,16].indexOf(n.length)>-1?o(t,n):console.error("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax")}else m[0]instanceof u?o(t,m[0].toArray()):Array.isArray(m[0])?o(t,m[0]):Array.isArray(m)&&o(t,m);return t},u.prototype.toString=function(){return(this.is2D?"matrix":"matrix3d")+"("+this.toArray(1).join(",")+")"},u.prototype.toArray=function(m){var t=this;return t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:m?[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]:[t.m11,t.m21,t.m31,t.m41,t.m12,t.m22,t.m32,t.m42,t.m13,t.m23,t.m33,t.m43,t.m14,t.m24,t.m34,t.m44]},u.prototype.multiply=function(m){return a(this,m)},u.prototype.translate=function(t,r,n){return null==n&&(n=0),null==r&&(r=0),a(this,m(t,r,n))},u.prototype.scale=function(m,t,r){return null==t&&(t=m),null==r&&(r=m),a(this,n(m,t,r))},u.prototype.rotate=function(m,r,n){return null==r&&(r=0),null==n&&(n=m,m=0),a(this,t(m,r,n))},u.prototype.rotateAxisAngle=function(m,t,n,e){return 4!==arguments.length?(console.error("CSSMatrix: expecting 4 values"),this):a(this,r(m,t,n,e))},u.prototype.skewX=function(m){return a(this,e(m))},u.prototype.skewY=function(m){return a(this,i(m))},u.prototype.setIdentity=function(){return o(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},s.isIdentity.get=function(){var m=this;return 1==m.m11&&0==m.m12&&0==m.m13&&0==m.m14&&0==m.m21&&1==m.m22&&0==m.m23&&0==m.m24&&0==m.m31&&0==m.m32&&1==m.m33&&0==m.m34&&0==m.m41&&0==m.m42&&0==m.m43&&1==m.m44},s.isIdentity.set=function(m){this.isIdentity=m},s.is2D.get=function(){var m=this;return 0==m.m31&&0==m.m32&&1==m.m33&&0==m.m34&&0==m.m43&&1==m.m44},s.is2D.set=function(m){this.is2D=m},u.prototype.transformPoint=function(t){var r=m(t.x,t.y,t.z);return r.m44=t.w||1,{x:(r=this.multiply(r)).m41,y:r.m42,z:r.m43,w:r.m44}},Object.defineProperties(u.prototype,s),u.Translate=m,u.Rotate=t,u.RotateAxisAngle=r,u.Scale=n,u.SkewX=e,u.SkewY=i,u.Multiply=a,u.fromMatrix=function(m){return new u([m.m11,m.m21,m.m31,m.m41,m.m12,m.m22,m.m32,m.m42,m.m13,m.m23,m.m33,m.m43,m.m14,m.m24,m.m34,m.m44])},u.fromArray=function(m){return o(new u,m)},u.feedFromArray=o;export default u; |
/*! | ||
* DOMMatrix v0.0.4a (https://github.com/thednp/dommatrix) | ||
* DOMMatrix v0.0.4b (https://github.com/thednp/dommatrix) | ||
* Copyright 2020 © thednp | ||
@@ -4,0 +4,0 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE) |
@@ -1,2 +0,2 @@ | ||
// DOMMatrix v0.0.4a | thednp © 2020 | MIT-License | ||
// DOMMatrix v0.0.4b | thednp © 2020 | MIT-License | ||
!function(m,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(m="undefined"!=typeof globalThis?globalThis:m||self).CSSMatrix=t()}(this,(function(){"use strict";function m(m,t,n){var r=new u;return r.m41=r.e=m,r.m42=r.f=t,r.m43=n,r}function t(m,t,n){var r=new u;m*=Math.PI/180,t*=Math.PI/180,n*=Math.PI/180;var e=Math.cos(m),i=-Math.sin(m),o=Math.cos(t),a=-Math.sin(t),s=Math.cos(n),f=-Math.sin(n);return r.m11=r.a=o*s,r.m12=r.b=-o*f,r.m13=a,r.m21=r.c=i*a*s+e*f,r.m22=r.d=e*s-i*a*f,r.m23=-i*o,r.m31=i*f-e*a*s,r.m32=i*s+e*a*f,r.m33=e*o,r}function n(m,t,n,r){r*=Math.PI/360;var e=Math.sin(r),i=Math.cos(r),o=e*e,a=Math.sqrt(m*m+t*t+n*n);0===a?(m=0,t=0,n=1):(m/=a,t/=a,n/=a);var s=m*m,f=t*t,c=n*n,l=new u;return l.m11=l.a=1-2*(f+c)*o,l.m12=l.b=2*(m*t*o+n*e*i),l.m13=2*(m*n*o-t*e*i),l.m21=l.c=2*(t*m*o-n*e*i),l.m22=l.d=1-2*(c+s)*o,l.m23=2*(t*n*o+m*e*i),l.m31=2*(n*m*o+t*e*i),l.m32=2*(n*t*o-m*e*i),l.m33=1-2*(s+f)*o,l.m14=l.m24=l.m34=0,l.m41=l.e=l.m42=l.f=l.m43=0,l.m44=1,l}function r(m,t,n){var r=new u;return r.m11=r.a=m,r.m22=r.d=t,r.m33=n,r}function e(m){m*=Math.PI/180;var t=new u;return t.m21=t.c=Math.tan(m),t}function i(m){m*=Math.PI/180;var t=new u;return t.m12=t.b=Math.tan(m),t}function o(m,t){var n=t.m11*m.m11+t.m12*m.m21+t.m13*m.m31+t.m14*m.m41,r=t.m11*m.m12+t.m12*m.m22+t.m13*m.m32+t.m14*m.m42,e=t.m11*m.m13+t.m12*m.m23+t.m13*m.m33+t.m14*m.m43,i=t.m11*m.m14+t.m12*m.m24+t.m13*m.m34+t.m14*m.m44,o=t.m21*m.m11+t.m22*m.m21+t.m23*m.m31+t.m24*m.m41,a=t.m21*m.m12+t.m22*m.m22+t.m23*m.m32+t.m24*m.m42,s=t.m21*m.m13+t.m22*m.m23+t.m23*m.m33+t.m24*m.m43,f=t.m21*m.m14+t.m22*m.m24+t.m23*m.m34+t.m24*m.m44,c=t.m31*m.m11+t.m32*m.m21+t.m33*m.m31+t.m34*m.m41,l=t.m31*m.m12+t.m32*m.m22+t.m33*m.m32+t.m34*m.m42,h=t.m31*m.m13+t.m32*m.m23+t.m33*m.m33+t.m34*m.m43,p=t.m31*m.m14+t.m32*m.m24+t.m33*m.m34+t.m34*m.m44,y=t.m41*m.m11+t.m42*m.m21+t.m43*m.m31+t.m44*m.m41,d=t.m41*m.m12+t.m42*m.m22+t.m43*m.m32+t.m44*m.m42,M=t.m41*m.m13+t.m42*m.m23+t.m43*m.m33+t.m44*m.m43,x=t.m41*m.m14+t.m42*m.m24+t.m43*m.m34+t.m44*m.m44;return new u([n,o,c,y,r,a,l,d,e,s,h,M,i,f,p,x])}function a(m,t){var n=Array.from(t);return 16==n.length?(m.m11=m.a=n[0],m.m21=m.c=n[1],m.m31=n[2],m.m41=m.e=n[3],m.m12=m.b=n[4],m.m22=m.d=n[5],m.m32=n[6],m.m42=m.f=n[7],m.m13=n[8],m.m23=n[9],m.m33=n[10],m.m43=n[11],m.m14=n[12],m.m24=n[13],m.m34=n[14],m.m44=n[15]):6==n.length?(m.m11=m.a=n[0],m.m12=m.b=n[1],m.m14=m.e=n[4],m.m21=m.c=n[2],m.m22=m.d=n[3],m.m24=m.f=n[5]):console.error("CSSMatrix: expecting a 6/16 values Array"),m}var u=function(){for(var m=[],t=arguments.length;t--;)m[t]=arguments[t];return this.setIdentity(),m&&m.length&&this.setMatrixValue(m)},s={isIdentity:{configurable:!0},is2D:{configurable:!0}};return u.prototype.setMatrixValue=function(m){var t=this;if(!m||!m.length)return t;if(m.length&&"string"==typeof m[0]&&m[0].length){var n,r,e=String(m[0]).trim();if("none"==e)return t;n=e.slice(0,e.indexOf("(")),r=e.slice("matrix"===n?7:9,-1).split(",").map((function(m){return Math.abs(m)<1e-6?0:+m})),[6,16].indexOf(r.length)>-1?a(t,r):console.error("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax")}else m[0]instanceof u?a(t,m[0].toArray()):Array.isArray(m[0])?a(t,m[0]):Array.isArray(m)&&a(t,m);return t},u.prototype.toString=function(){return(this.is2D?"matrix":"matrix3d")+"("+this.toArray(1).join(",")+")"},u.prototype.toArray=function(m){var t=this;return t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:m?[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]:[t.m11,t.m21,t.m31,t.m41,t.m12,t.m22,t.m32,t.m42,t.m13,t.m23,t.m33,t.m43,t.m14,t.m24,t.m34,t.m44]},u.prototype.multiply=function(m){return o(this,m)},u.prototype.translate=function(t,n,r){return null==r&&(r=0),null==n&&(n=0),o(this,m(t,n,r))},u.prototype.scale=function(m,t,n){return null==t&&(t=m),null==n&&(n=m),o(this,r(m,t,n))},u.prototype.rotate=function(m,n,r){return null==n&&(n=0),null==r&&(r=m,m=0),o(this,t(m,n,r))},u.prototype.rotateAxisAngle=function(m,t,r,e){return 4!==arguments.length?(console.error("CSSMatrix: expecting 4 values"),this):o(this,n(m,t,r,e))},u.prototype.skewX=function(m){return o(this,e(m))},u.prototype.skewY=function(m){return o(this,i(m))},u.prototype.setIdentity=function(){return a(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},s.isIdentity.get=function(){var m=this;return 1==m.m11&&0==m.m12&&0==m.m13&&0==m.m14&&0==m.m21&&1==m.m22&&0==m.m23&&0==m.m24&&0==m.m31&&0==m.m32&&1==m.m33&&0==m.m34&&0==m.m41&&0==m.m42&&0==m.m43&&1==m.m44},s.isIdentity.set=function(m){this.isIdentity=m},s.is2D.get=function(){var m=this;return 0==m.m31&&0==m.m32&&1==m.m33&&0==m.m34&&0==m.m43&&1==m.m44},s.is2D.set=function(m){this.is2D=m},u.prototype.transformPoint=function(t){var n=m(t.x,t.y,t.z);return n.m44=t.w||1,{x:(n=this.multiply(n)).m41,y:n.m42,z:n.m43,w:n.m44}},Object.defineProperties(u.prototype,s),u.Translate=m,u.Rotate=t,u.RotateAxisAngle=n,u.Scale=r,u.SkewX=e,u.SkewY=i,u.Multiply=o,u.fromMatrix=function(m){return new u([m.m11,m.m21,m.m31,m.m41,m.m12,m.m22,m.m32,m.m42,m.m13,m.m23,m.m33,m.m43,m.m14,m.m24,m.m34,m.m44])},u.fromArray=function(m){return a(new u,m)},u.feedFromArray=a,u})); |
{ | ||
"name": "dommatrix", | ||
"version": "0.0.4a", | ||
"version": "0.0.4b", | ||
"description": "ES6+ shim for DOMMatrix", | ||
@@ -5,0 +5,0 @@ "main": "dist/dommatrix.min.js", |
@@ -71,4 +71,6 @@ # DOMMatrix shim | ||
let myMatrix = new CSSMatrix().translate(15) | ||
// equivalent to | ||
let myMatrix = new CSSMatrix().translate(15,0) | ||
// equivalent to | ||
@@ -84,2 +86,26 @@ let myMatrix = new CSSMatrix().translate(15,0,0) | ||
# Adding Perspective To Matrix | ||
```js | ||
import CSSMatrix from 'dommatrix' | ||
// perspective | ||
let perspective = 400 | ||
// init | ||
let myMatrix = new CSSMatrix() | ||
// set perspective | ||
myMatrix.m34 = -1/perspective | ||
// now your matrix is always 3D | ||
// we can apply any 3D transformation | ||
myMatrix = myMatrix.rotate(45,0,0) | ||
// this matrix is now equivalent with this | ||
// CSS transformation syntax | ||
// perspective(400px) rotateX(45deg) | ||
``` | ||
# Standard Methods - described in the W3C draft | ||
@@ -86,0 +112,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
64454
274
1