Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dommatrix

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dommatrix - npm Package Compare versions

Comparing version 0.0.4-b to 0.0.4-c

288

dist/dommatrix.esm.js
/*!
* DOMMatrix v0.0.4b (https://github.com/thednp/dommatrix)
* DOMMatrix v0.0.4c (https://github.com/thednp/dommatrix)
* Copyright 2020 © thednp
* Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE)
*/
function Translate(x, y, z){
var CSSMatrix = function CSSMatrix(){
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
this.setIdentity();
return args && args.length && this.setMatrixValue(args)
};
var prototypeAccessors = { isIdentity: { configurable: true },is2D: { configurable: true } };
CSSMatrix.prototype.setMatrixValue = function setMatrixValue (source){
var m = this;
if (!source || !source.length) {
return m
} else if (source.length && typeof source[0] === 'string' && source[0].length) {
var string = String(source[0]).trim(), type = '', values = [];
if (string == 'none') { return m; }
type = string.slice(0, string.indexOf('('));
values = string.slice((type === 'matrix' ? 7 : 9), -1).split(',')
.map(function (n){ return Math.abs(n) < 1e-6 ? 0 : +n; });
if ([6,16].indexOf(values.length)>-1){
feedFromArray(m,values);
} else {
throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax")
}
} else if (source[0] instanceof CSSMatrix) {
feedFromArray(m,source[0].toArray());
} else if (Array.isArray(source[0])) {
feedFromArray(m,source[0]);
} else if (Array.isArray(source)) {
feedFromArray(m,source);
}
return m
};
CSSMatrix.prototype.toString = function toString (){
var m = this, type = m.is2D ? 'matrix' : 'matrix3d';
return (type + "(" + (m.toArray(1).join(',')) + ")")
};
CSSMatrix.prototype.toArray = function toArray (transposed){
var m = this;
return m.is2D ? [ m.a, m.b, m.c, m.d, m.e, m.f ]
: transposed
?[m.m11, m.m12, m.m13, m.m14,
m.m21, m.m22, m.m23, m.m24,
m.m31, m.m32, m.m33, m.m34,
m.m41, m.m42, m.m43, m.m44]
:[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]
};
CSSMatrix.prototype.multiply = function multiply (m2){
return Multiply(this,m2)
};
CSSMatrix.prototype.translate = function translate (x, y, z){
if (z == null) { z = 0; }
if (y == null) { y = 0; }
return Multiply(this,Translate(x, y, z))
};
CSSMatrix.prototype.scale = function scale (x, y, z){
if (y == null) { y = x; }
if (z == null) { z = x; }
return Multiply(this,Scale(x, y, z))
};
CSSMatrix.prototype.rotate = function rotate (rx, ry, rz){
if (ry == null) { ry = 0; }
if (rz == null) {rz = rx; rx = 0;}
return Multiply(this,Rotate(rx, ry, rz))
};
CSSMatrix.prototype.rotateAxisAngle = function rotateAxisAngle (x, y, z, angle){
if (arguments.length!==4){
throw new TypeError("CSSMatrix: expecting 4 values")
}
return Multiply(this,RotateAxisAngle(x, y, z, angle))
};
CSSMatrix.prototype.skewX = function skewX (angle){
return Multiply(this,SkewX(angle))
};
CSSMatrix.prototype.skewY = function skewY (angle){
return Multiply(this,SkewY(angle))
};
CSSMatrix.prototype.setIdentity = function setIdentity (){
var identity = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
return feedFromArray(this,identity)
};
prototypeAccessors.isIdentity.get = function (){
var m = this;
return (m.m11 == 1 && m.m12 == 0 && m.m13 == 0 && m.m14 == 0 &&
m.m21 == 0 && m.m22 == 1 && m.m23 == 0 && m.m24 == 0 &&
m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 &&
m.m41 == 0 && m.m42 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.isIdentity.set = function (value){
this.isIdentity = value;
};
prototypeAccessors.is2D.get = function (){
var m = this;
return (m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.is2D.set = function (value){
this.is2D = value;
};
CSSMatrix.prototype.transformPoint = function transformPoint (v){
var _m = this, m = Translate(v.x, v.y, v.z);
m.m44 = v.w || 1;
m = _m.multiply(m);
return {
x: m.m41,
y: m.m42,
z: m.m43,
w: m.m44
}
};
CSSMatrix.prototype.transform = function transform (t){
var m = this,
x = m.m11 * t.x + m.m12 * t.y + m.m13 * t.z + m.m14 * t.w,
y = m.m21 * t.x + m.m22 * t.y + m.m23 * t.z + m.m24 * t.w,
z = m.m31 * t.x + m.m32 * t.y + m.m33 * t.z + m.m34 * t.w,
w = m.m41 * t.x + m.m42 * t.y + m.m43 * t.z + m.m44 * t.w;
return {
x: x / w,
y: y / w,
z: z / w,
w : w
}
};
Object.defineProperties( CSSMatrix.prototype, prototypeAccessors );
CSSMatrix.Translate = function Translate(x, y, z){
var m = new CSSMatrix();

@@ -12,4 +136,4 @@ m.m41 = m.e = x;

return m
}
function Rotate(rx, ry, rz){
};
CSSMatrix.Rotate = function Rotate(rx, ry, rz){
var m = new CSSMatrix();

@@ -32,4 +156,4 @@ rx *= Math.PI / 180;

return m
}
function RotateAxisAngle(x, y, z, angle){
};
CSSMatrix.RotateAxisAngle = function RotateAxisAngle(x, y, z, angle){
angle *= Math.PI / 360;

@@ -64,4 +188,4 @@ var sinA = Math.sin(angle),

return m
}
function Scale(x, y, z){
};
CSSMatrix.Scale = function Scale(x, y, z){
var m = new CSSMatrix();

@@ -72,4 +196,4 @@ m.m11 = m.a = x;

return m
}
function SkewX(angle){
};
CSSMatrix.SkewX = function SkewX(angle){
angle *= Math.PI / 180;

@@ -79,4 +203,4 @@ var m = new CSSMatrix();

return m
}
function SkewY(angle){
};
CSSMatrix.SkewY = function SkewY(angle){
angle *= Math.PI / 180;

@@ -86,4 +210,4 @@ var m = new CSSMatrix();

return m
}
function Multiply(m1, m2){
};
CSSMatrix.Multiply = function Multiply(m1, m2){
var m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41,

@@ -110,4 +234,4 @@ m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42,

m14, m24, m34, m44])
}
function fromMatrix(m){
};
CSSMatrix.fromMatrix = function fromMatrix(m){
return new CSSMatrix(

@@ -118,7 +242,7 @@ [m.m11, m.m21, m.m31, m.m41,

m.m14, m.m24, m.m34, m.m44])
}
function fromArray(a){
};
CSSMatrix.fromArray = function fromArray(a){
return feedFromArray(new CSSMatrix(),a)
}
function feedFromArray(m,array){
};
CSSMatrix.feedFromArray = function feedFromArray(m,array){
var a = Array.from(array);

@@ -150,129 +274,7 @@ if (a.length == 16){

} else {
console.error("CSSMatrix: expecting a 6/16 values Array");
throw new TypeError("CSSMatrix: expecting a 6/16 values Array")
}
return m
}
var CSSMatrix = function CSSMatrix(){
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
this.setIdentity();
return args && args.length && this.setMatrixValue(args)
};
var prototypeAccessors = { isIdentity: { configurable: true },is2D: { configurable: true } };
CSSMatrix.prototype.setMatrixValue = function setMatrixValue (source){
var m = this;
if (!source || !source.length) {
return m
} else if (source.length && typeof source[0] === 'string' && source[0].length) {
var string = String(source[0]).trim(), type = '', values = [];
if (string == 'none') { return m; }
type = string.slice(0, string.indexOf('('));
values = string.slice((type === 'matrix' ? 7 : 9), -1).split(',')
.map(function (n){ return Math.abs(n) < 1e-6 ? 0 : +n; });
if ([6,16].indexOf(values.length)>-1){
feedFromArray(m,values);
} else {
console.error("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");
}
} else if (source[0] instanceof CSSMatrix) {
feedFromArray(m,source[0].toArray());
} else if (Array.isArray(source[0])) {
feedFromArray(m,source[0]);
} else if (Array.isArray(source)) {
feedFromArray(m,source);
}
return m
};
CSSMatrix.prototype.toString = function toString (){
var m = this, type = m.is2D ? 'matrix' : 'matrix3d';
return (type + "(" + (m.toArray(1).join(',')) + ")")
};
CSSMatrix.prototype.toArray = function toArray (transposed){
var m = this;
return m.is2D ? [ m.a, m.b, m.c, m.d, m.e, m.f ]
: transposed
?[m.m11, m.m12, m.m13, m.m14,
m.m21, m.m22, m.m23, m.m24,
m.m31, m.m32, m.m33, m.m34,
m.m41, m.m42, m.m43, m.m44]
:[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]
};
CSSMatrix.prototype.multiply = function multiply (m2){
return Multiply(this,m2)
};
CSSMatrix.prototype.translate = function translate (x, y, z){
if (z == null) { z = 0; }
if (y == null) { y = 0; }
return Multiply(this,Translate(x, y, z))
};
CSSMatrix.prototype.scale = function scale (x, y, z){
if (y == null) { y = x; }
if (z == null) { z = x; }
return Multiply(this,Scale(x, y, z))
};
CSSMatrix.prototype.rotate = function rotate (rx, ry, rz){
if (ry == null) { ry = 0; }
if (rz == null) {rz = rx; rx = 0;}
return Multiply(this,Rotate(rx, ry, rz))
};
CSSMatrix.prototype.rotateAxisAngle = function rotateAxisAngle (x, y, z, angle){
if (arguments.length!==4){
console.error("CSSMatrix: expecting 4 values");
return this
}
return Multiply(this,RotateAxisAngle(x, y, z, angle))
};
CSSMatrix.prototype.skewX = function skewX (angle){
return Multiply(this,SkewX(angle))
};
CSSMatrix.prototype.skewY = function skewY (angle){
return Multiply(this,SkewY(angle))
};
CSSMatrix.prototype.setIdentity = function setIdentity (){
var identity = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
return feedFromArray(this,identity)
};
prototypeAccessors.isIdentity.get = function (){
var m = this;
return (m.m11 == 1 && m.m12 == 0 && m.m13 == 0 && m.m14 == 0 &&
m.m21 == 0 && m.m22 == 1 && m.m23 == 0 && m.m24 == 0 &&
m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 &&
m.m41 == 0 && m.m42 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.isIdentity.set = function (value){
this.isIdentity = value;
};
prototypeAccessors.is2D.get = function (){
var m = this;
return (m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.is2D.set = function (value){
this.is2D = value;
};
CSSMatrix.prototype.transformPoint = function transformPoint (v){
var _m = this, m = Translate(v.x, v.y, v.z);
m.m44 = v.w || 1;
m = _m.multiply(m);
return {
x: m.m41,
y: m.m42,
z: m.m43,
w: m.m44
}
};
Object.defineProperties( CSSMatrix.prototype, prototypeAccessors );
CSSMatrix.Translate = Translate;
CSSMatrix.Rotate = Rotate;
CSSMatrix.RotateAxisAngle = RotateAxisAngle;
CSSMatrix.Scale = Scale;
CSSMatrix.SkewX = SkewX;
CSSMatrix.SkewY = SkewY;
CSSMatrix.Multiply = Multiply;
CSSMatrix.fromMatrix = fromMatrix;
CSSMatrix.fromArray = fromArray;
CSSMatrix.feedFromArray = feedFromArray;
export default CSSMatrix;

@@ -1,2 +0,2 @@

// 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.4c | thednp © 2020 | MIT-License
var m=function(){for(var m=[],t=arguments.length;t--;)m[t]=arguments[t];return this.setIdentity(),m&&m.length&&this.setMatrixValue(m)},t={isIdentity:{configurable:!0},is2D:{configurable:!0}};m.prototype.setMatrixValue=function(t){var r=this;if(!t||!t.length)return r;if(t.length&&"string"==typeof t[0]&&t[0].length){var e,n,i=String(t[0]).trim();if("none"==i)return r;if(e=i.slice(0,i.indexOf("(")),n=i.slice("matrix"===e?7:9,-1).split(",").map((function(m){return Math.abs(m)<1e-6?0:+m})),!([6,16].indexOf(n.length)>-1))throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");feedFromArray(r,n)}else t[0]instanceof m?feedFromArray(r,t[0].toArray()):Array.isArray(t[0])?feedFromArray(r,t[0]):Array.isArray(t)&&feedFromArray(r,t);return r},m.prototype.toString=function(){return(this.is2D?"matrix":"matrix3d")+"("+this.toArray(1).join(",")+")"},m.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]},m.prototype.multiply=function(m){return Multiply(this,m)},m.prototype.translate=function(m,t,r){return null==r&&(r=0),null==t&&(t=0),Multiply(this,Translate(m,t,r))},m.prototype.scale=function(m,t,r){return null==t&&(t=m),null==r&&(r=m),Multiply(this,Scale(m,t,r))},m.prototype.rotate=function(m,t,r){return null==t&&(t=0),null==r&&(r=m,m=0),Multiply(this,Rotate(m,t,r))},m.prototype.rotateAxisAngle=function(m,t,r,e){if(4!==arguments.length)throw new TypeError("CSSMatrix: expecting 4 values");return Multiply(this,RotateAxisAngle(m,t,r,e))},m.prototype.skewX=function(m){return Multiply(this,SkewX(m))},m.prototype.skewY=function(m){return Multiply(this,SkewY(m))},m.prototype.setIdentity=function(){return feedFromArray(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},t.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},t.isIdentity.set=function(m){this.isIdentity=m},t.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},t.is2D.set=function(m){this.is2D=m},m.prototype.transformPoint=function(m){var t=Translate(m.x,m.y,m.z);return t.m44=m.w||1,{x:(t=this.multiply(t)).m41,y:t.m42,z:t.m43,w:t.m44}},m.prototype.transform=function(m){var t=this,r=t.m11*m.x+t.m12*m.y+t.m13*m.z+t.m14*m.w,e=t.m21*m.x+t.m22*m.y+t.m23*m.z+t.m24*m.w,n=t.m31*m.x+t.m32*m.y+t.m33*m.z+t.m34*m.w,i=t.m41*m.x+t.m42*m.y+t.m43*m.z+t.m44*m.w;return{x:r/i,y:e/i,z:n/i,w:i}},Object.defineProperties(m.prototype,t),m.Translate=function(t,r,e){var n=new m;return n.m41=n.e=t,n.m42=n.f=r,n.m43=e,n},m.Rotate=function(t,r,e){var n=new m;t*=Math.PI/180,r*=Math.PI/180,e*=Math.PI/180;var i=Math.cos(t),a=-Math.sin(t),o=Math.cos(r),u=-Math.sin(r),s=Math.cos(e),l=-Math.sin(e);return n.m11=n.a=o*s,n.m12=n.b=-o*l,n.m13=u,n.m21=n.c=a*u*s+i*l,n.m22=n.d=i*s-a*u*l,n.m23=-a*o,n.m31=a*l-i*u*s,n.m32=a*s+i*u*l,n.m33=i*o,n},m.RotateAxisAngle=function(t,r,e,n){n*=Math.PI/360;var i=Math.sin(n),a=Math.cos(n),o=i*i,u=Math.sqrt(t*t+r*r+e*e);0===u?(t=0,r=0,e=1):(t/=u,r/=u,e/=u);var s=t*t,l=r*r,f=e*e,y=new m;return y.m11=y.a=1-2*(l+f)*o,y.m12=y.b=2*(t*r*o+e*i*a),y.m13=2*(t*e*o-r*i*a),y.m21=y.c=2*(r*t*o-e*i*a),y.m22=y.d=1-2*(f+s)*o,y.m23=2*(r*e*o+t*i*a),y.m31=2*(e*t*o+r*i*a),y.m32=2*(e*r*o-t*i*a),y.m33=1-2*(s+l)*o,y.m14=y.m24=y.m34=0,y.m41=y.e=y.m42=y.f=y.m43=0,y.m44=1,y},m.Scale=function(t,r,e){var n=new m;return n.m11=n.a=t,n.m22=n.d=r,n.m33=e,n},m.SkewX=function(t){t*=Math.PI/180;var r=new m;return r.m21=r.c=Math.tan(t),r},m.SkewY=function(t){t*=Math.PI/180;var r=new m;return r.m12=r.b=Math.tan(t),r},m.Multiply=function(t,r){var e=r.m11*t.m11+r.m12*t.m21+r.m13*t.m31+r.m14*t.m41,n=r.m11*t.m12+r.m12*t.m22+r.m13*t.m32+r.m14*t.m42,i=r.m11*t.m13+r.m12*t.m23+r.m13*t.m33+r.m14*t.m43,a=r.m11*t.m14+r.m12*t.m24+r.m13*t.m34+r.m14*t.m44,o=r.m21*t.m11+r.m22*t.m21+r.m23*t.m31+r.m24*t.m41,u=r.m21*t.m12+r.m22*t.m22+r.m23*t.m32+r.m24*t.m42,s=r.m21*t.m13+r.m22*t.m23+r.m23*t.m33+r.m24*t.m43,l=r.m21*t.m14+r.m22*t.m24+r.m23*t.m34+r.m24*t.m44,f=r.m31*t.m11+r.m32*t.m21+r.m33*t.m31+r.m34*t.m41,y=r.m31*t.m12+r.m32*t.m22+r.m33*t.m32+r.m34*t.m42,c=r.m31*t.m13+r.m32*t.m23+r.m33*t.m33+r.m34*t.m43,h=r.m31*t.m14+r.m32*t.m24+r.m33*t.m34+r.m34*t.m44,p=r.m41*t.m11+r.m42*t.m21+r.m43*t.m31+r.m44*t.m41,M=r.m41*t.m12+r.m42*t.m22+r.m43*t.m32+r.m44*t.m42,w=r.m41*t.m13+r.m42*t.m23+r.m43*t.m33+r.m44*t.m43,x=r.m41*t.m14+r.m42*t.m24+r.m43*t.m34+r.m44*t.m44;return new m([e,o,f,p,n,u,y,M,i,s,c,w,a,l,h,x])},m.fromMatrix=function(t){return new m([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])},m.fromArray=function(t){return feedFromArray(new m,t)},m.feedFromArray=function(m,t){var r=Array.from(t);if(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];else{if(6!=r.length)throw new TypeError("CSSMatrix: expecting a 6/16 values Array");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]}return m};export default m;
/*!
* DOMMatrix v0.0.4b (https://github.com/thednp/dommatrix)
* DOMMatrix v0.0.4c (https://github.com/thednp/dommatrix)
* Copyright 2020 © thednp

@@ -12,3 +12,127 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE)

function Translate(x, y, z){
var CSSMatrix = function CSSMatrix(){
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
this.setIdentity();
return args && args.length && this.setMatrixValue(args)
};
var prototypeAccessors = { isIdentity: { configurable: true },is2D: { configurable: true } };
CSSMatrix.prototype.setMatrixValue = function setMatrixValue (source){
var m = this;
if (!source || !source.length) {
return m
} else if (source.length && typeof source[0] === 'string' && source[0].length) {
var string = String(source[0]).trim(), type = '', values = [];
if (string == 'none') { return m; }
type = string.slice(0, string.indexOf('('));
values = string.slice((type === 'matrix' ? 7 : 9), -1).split(',')
.map(function (n){ return Math.abs(n) < 1e-6 ? 0 : +n; });
if ([6,16].indexOf(values.length)>-1){
feedFromArray(m,values);
} else {
throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax")
}
} else if (source[0] instanceof CSSMatrix) {
feedFromArray(m,source[0].toArray());
} else if (Array.isArray(source[0])) {
feedFromArray(m,source[0]);
} else if (Array.isArray(source)) {
feedFromArray(m,source);
}
return m
};
CSSMatrix.prototype.toString = function toString (){
var m = this, type = m.is2D ? 'matrix' : 'matrix3d';
return (type + "(" + (m.toArray(1).join(',')) + ")")
};
CSSMatrix.prototype.toArray = function toArray (transposed){
var m = this;
return m.is2D ? [ m.a, m.b, m.c, m.d, m.e, m.f ]
: transposed
?[m.m11, m.m12, m.m13, m.m14,
m.m21, m.m22, m.m23, m.m24,
m.m31, m.m32, m.m33, m.m34,
m.m41, m.m42, m.m43, m.m44]
:[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]
};
CSSMatrix.prototype.multiply = function multiply (m2){
return Multiply(this,m2)
};
CSSMatrix.prototype.translate = function translate (x, y, z){
if (z == null) { z = 0; }
if (y == null) { y = 0; }
return Multiply(this,Translate(x, y, z))
};
CSSMatrix.prototype.scale = function scale (x, y, z){
if (y == null) { y = x; }
if (z == null) { z = x; }
return Multiply(this,Scale(x, y, z))
};
CSSMatrix.prototype.rotate = function rotate (rx, ry, rz){
if (ry == null) { ry = 0; }
if (rz == null) {rz = rx; rx = 0;}
return Multiply(this,Rotate(rx, ry, rz))
};
CSSMatrix.prototype.rotateAxisAngle = function rotateAxisAngle (x, y, z, angle){
if (arguments.length!==4){
throw new TypeError("CSSMatrix: expecting 4 values")
}
return Multiply(this,RotateAxisAngle(x, y, z, angle))
};
CSSMatrix.prototype.skewX = function skewX (angle){
return Multiply(this,SkewX(angle))
};
CSSMatrix.prototype.skewY = function skewY (angle){
return Multiply(this,SkewY(angle))
};
CSSMatrix.prototype.setIdentity = function setIdentity (){
var identity = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
return feedFromArray(this,identity)
};
prototypeAccessors.isIdentity.get = function (){
var m = this;
return (m.m11 == 1 && m.m12 == 0 && m.m13 == 0 && m.m14 == 0 &&
m.m21 == 0 && m.m22 == 1 && m.m23 == 0 && m.m24 == 0 &&
m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 &&
m.m41 == 0 && m.m42 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.isIdentity.set = function (value){
this.isIdentity = value;
};
prototypeAccessors.is2D.get = function (){
var m = this;
return (m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.is2D.set = function (value){
this.is2D = value;
};
CSSMatrix.prototype.transformPoint = function transformPoint (v){
var _m = this, m = Translate(v.x, v.y, v.z);
m.m44 = v.w || 1;
m = _m.multiply(m);
return {
x: m.m41,
y: m.m42,
z: m.m43,
w: m.m44
}
};
CSSMatrix.prototype.transform = function transform (t){
var m = this,
x = m.m11 * t.x + m.m12 * t.y + m.m13 * t.z + m.m14 * t.w,
y = m.m21 * t.x + m.m22 * t.y + m.m23 * t.z + m.m24 * t.w,
z = m.m31 * t.x + m.m32 * t.y + m.m33 * t.z + m.m34 * t.w,
w = m.m41 * t.x + m.m42 * t.y + m.m43 * t.z + m.m44 * t.w;
return {
x: x / w,
y: y / w,
z: z / w,
w : w
}
};
Object.defineProperties( CSSMatrix.prototype, prototypeAccessors );
CSSMatrix.Translate = function Translate(x, y, z){
var m = new CSSMatrix();

@@ -19,4 +143,4 @@ m.m41 = m.e = x;

return m
}
function Rotate(rx, ry, rz){
};
CSSMatrix.Rotate = function Rotate(rx, ry, rz){
var m = new CSSMatrix();

@@ -39,4 +163,4 @@ rx *= Math.PI / 180;

return m
}
function RotateAxisAngle(x, y, z, angle){
};
CSSMatrix.RotateAxisAngle = function RotateAxisAngle(x, y, z, angle){
angle *= Math.PI / 360;

@@ -71,4 +195,4 @@ var sinA = Math.sin(angle),

return m
}
function Scale(x, y, z){
};
CSSMatrix.Scale = function Scale(x, y, z){
var m = new CSSMatrix();

@@ -79,4 +203,4 @@ m.m11 = m.a = x;

return m
}
function SkewX(angle){
};
CSSMatrix.SkewX = function SkewX(angle){
angle *= Math.PI / 180;

@@ -86,4 +210,4 @@ var m = new CSSMatrix();

return m
}
function SkewY(angle){
};
CSSMatrix.SkewY = function SkewY(angle){
angle *= Math.PI / 180;

@@ -93,4 +217,4 @@ var m = new CSSMatrix();

return m
}
function Multiply(m1, m2){
};
CSSMatrix.Multiply = function Multiply(m1, m2){
var m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41,

@@ -117,4 +241,4 @@ m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42,

m14, m24, m34, m44])
}
function fromMatrix(m){
};
CSSMatrix.fromMatrix = function fromMatrix(m){
return new CSSMatrix(

@@ -125,7 +249,7 @@ [m.m11, m.m21, m.m31, m.m41,

m.m14, m.m24, m.m34, m.m44])
}
function fromArray(a){
};
CSSMatrix.fromArray = function fromArray(a){
return feedFromArray(new CSSMatrix(),a)
}
function feedFromArray(m,array){
};
CSSMatrix.feedFromArray = function feedFromArray(m,array){
var a = Array.from(array);

@@ -157,128 +281,6 @@ if (a.length == 16){

} else {
console.error("CSSMatrix: expecting a 6/16 values Array");
throw new TypeError("CSSMatrix: expecting a 6/16 values Array")
}
return m
}
var CSSMatrix = function CSSMatrix(){
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
this.setIdentity();
return args && args.length && this.setMatrixValue(args)
};
var prototypeAccessors = { isIdentity: { configurable: true },is2D: { configurable: true } };
CSSMatrix.prototype.setMatrixValue = function setMatrixValue (source){
var m = this;
if (!source || !source.length) {
return m
} else if (source.length && typeof source[0] === 'string' && source[0].length) {
var string = String(source[0]).trim(), type = '', values = [];
if (string == 'none') { return m; }
type = string.slice(0, string.indexOf('('));
values = string.slice((type === 'matrix' ? 7 : 9), -1).split(',')
.map(function (n){ return Math.abs(n) < 1e-6 ? 0 : +n; });
if ([6,16].indexOf(values.length)>-1){
feedFromArray(m,values);
} else {
console.error("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");
}
} else if (source[0] instanceof CSSMatrix) {
feedFromArray(m,source[0].toArray());
} else if (Array.isArray(source[0])) {
feedFromArray(m,source[0]);
} else if (Array.isArray(source)) {
feedFromArray(m,source);
}
return m
};
CSSMatrix.prototype.toString = function toString (){
var m = this, type = m.is2D ? 'matrix' : 'matrix3d';
return (type + "(" + (m.toArray(1).join(',')) + ")")
};
CSSMatrix.prototype.toArray = function toArray (transposed){
var m = this;
return m.is2D ? [ m.a, m.b, m.c, m.d, m.e, m.f ]
: transposed
?[m.m11, m.m12, m.m13, m.m14,
m.m21, m.m22, m.m23, m.m24,
m.m31, m.m32, m.m33, m.m34,
m.m41, m.m42, m.m43, m.m44]
:[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]
};
CSSMatrix.prototype.multiply = function multiply (m2){
return Multiply(this,m2)
};
CSSMatrix.prototype.translate = function translate (x, y, z){
if (z == null) { z = 0; }
if (y == null) { y = 0; }
return Multiply(this,Translate(x, y, z))
};
CSSMatrix.prototype.scale = function scale (x, y, z){
if (y == null) { y = x; }
if (z == null) { z = x; }
return Multiply(this,Scale(x, y, z))
};
CSSMatrix.prototype.rotate = function rotate (rx, ry, rz){
if (ry == null) { ry = 0; }
if (rz == null) {rz = rx; rx = 0;}
return Multiply(this,Rotate(rx, ry, rz))
};
CSSMatrix.prototype.rotateAxisAngle = function rotateAxisAngle (x, y, z, angle){
if (arguments.length!==4){
console.error("CSSMatrix: expecting 4 values");
return this
}
return Multiply(this,RotateAxisAngle(x, y, z, angle))
};
CSSMatrix.prototype.skewX = function skewX (angle){
return Multiply(this,SkewX(angle))
};
CSSMatrix.prototype.skewY = function skewY (angle){
return Multiply(this,SkewY(angle))
};
CSSMatrix.prototype.setIdentity = function setIdentity (){
var identity = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
return feedFromArray(this,identity)
};
prototypeAccessors.isIdentity.get = function (){
var m = this;
return (m.m11 == 1 && m.m12 == 0 && m.m13 == 0 && m.m14 == 0 &&
m.m21 == 0 && m.m22 == 1 && m.m23 == 0 && m.m24 == 0 &&
m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 &&
m.m41 == 0 && m.m42 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.isIdentity.set = function (value){
this.isIdentity = value;
};
prototypeAccessors.is2D.get = function (){
var m = this;
return (m.m31 == 0 && m.m32 == 0 && m.m33 == 1 && m.m34 == 0 && m.m43 == 0 && m.m44 == 1)
};
prototypeAccessors.is2D.set = function (value){
this.is2D = value;
};
CSSMatrix.prototype.transformPoint = function transformPoint (v){
var _m = this, m = Translate(v.x, v.y, v.z);
m.m44 = v.w || 1;
m = _m.multiply(m);
return {
x: m.m41,
y: m.m42,
z: m.m43,
w: m.m44
}
};
Object.defineProperties( CSSMatrix.prototype, prototypeAccessors );
CSSMatrix.Translate = Translate;
CSSMatrix.Rotate = Rotate;
CSSMatrix.RotateAxisAngle = RotateAxisAngle;
CSSMatrix.Scale = Scale;
CSSMatrix.SkewX = SkewX;
CSSMatrix.SkewY = SkewY;
CSSMatrix.Multiply = Multiply;
CSSMatrix.fromMatrix = fromMatrix;
CSSMatrix.fromArray = fromArray;
CSSMatrix.feedFromArray = feedFromArray;

@@ -285,0 +287,0 @@ return CSSMatrix;

@@ -1,2 +0,2 @@

// 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}));
// DOMMatrix v0.0.4c | 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";var m=function(){for(var m=[],t=arguments.length;t--;)m[t]=arguments[t];return this.setIdentity(),m&&m.length&&this.setMatrixValue(m)},t={isIdentity:{configurable:!0},is2D:{configurable:!0}};return m.prototype.setMatrixValue=function(t){var r=this;if(!t||!t.length)return r;if(t.length&&"string"==typeof t[0]&&t[0].length){var e,n,i=String(t[0]).trim();if("none"==i)return r;if(e=i.slice(0,i.indexOf("(")),n=i.slice("matrix"===e?7:9,-1).split(",").map((function(m){return Math.abs(m)<1e-6?0:+m})),!([6,16].indexOf(n.length)>-1))throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");feedFromArray(r,n)}else t[0]instanceof m?feedFromArray(r,t[0].toArray()):Array.isArray(t[0])?feedFromArray(r,t[0]):Array.isArray(t)&&feedFromArray(r,t);return r},m.prototype.toString=function(){return(this.is2D?"matrix":"matrix3d")+"("+this.toArray(1).join(",")+")"},m.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]},m.prototype.multiply=function(m){return Multiply(this,m)},m.prototype.translate=function(m,t,r){return null==r&&(r=0),null==t&&(t=0),Multiply(this,Translate(m,t,r))},m.prototype.scale=function(m,t,r){return null==t&&(t=m),null==r&&(r=m),Multiply(this,Scale(m,t,r))},m.prototype.rotate=function(m,t,r){return null==t&&(t=0),null==r&&(r=m,m=0),Multiply(this,Rotate(m,t,r))},m.prototype.rotateAxisAngle=function(m,t,r,e){if(4!==arguments.length)throw new TypeError("CSSMatrix: expecting 4 values");return Multiply(this,RotateAxisAngle(m,t,r,e))},m.prototype.skewX=function(m){return Multiply(this,SkewX(m))},m.prototype.skewY=function(m){return Multiply(this,SkewY(m))},m.prototype.setIdentity=function(){return feedFromArray(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},t.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},t.isIdentity.set=function(m){this.isIdentity=m},t.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},t.is2D.set=function(m){this.is2D=m},m.prototype.transformPoint=function(m){var t=Translate(m.x,m.y,m.z);return t.m44=m.w||1,{x:(t=this.multiply(t)).m41,y:t.m42,z:t.m43,w:t.m44}},m.prototype.transform=function(m){var t=this,r=t.m11*m.x+t.m12*m.y+t.m13*m.z+t.m14*m.w,e=t.m21*m.x+t.m22*m.y+t.m23*m.z+t.m24*m.w,n=t.m31*m.x+t.m32*m.y+t.m33*m.z+t.m34*m.w,i=t.m41*m.x+t.m42*m.y+t.m43*m.z+t.m44*m.w;return{x:r/i,y:e/i,z:n/i,w:i}},Object.defineProperties(m.prototype,t),m.Translate=function(t,r,e){var n=new m;return n.m41=n.e=t,n.m42=n.f=r,n.m43=e,n},m.Rotate=function(t,r,e){var n=new m;t*=Math.PI/180,r*=Math.PI/180,e*=Math.PI/180;var i=Math.cos(t),o=-Math.sin(t),a=Math.cos(r),u=-Math.sin(r),s=Math.cos(e),f=-Math.sin(e);return n.m11=n.a=a*s,n.m12=n.b=-a*f,n.m13=u,n.m21=n.c=o*u*s+i*f,n.m22=n.d=i*s-o*u*f,n.m23=-o*a,n.m31=o*f-i*u*s,n.m32=o*s+i*u*f,n.m33=i*a,n},m.RotateAxisAngle=function(t,r,e,n){n*=Math.PI/360;var i=Math.sin(n),o=Math.cos(n),a=i*i,u=Math.sqrt(t*t+r*r+e*e);0===u?(t=0,r=0,e=1):(t/=u,r/=u,e/=u);var s=t*t,f=r*r,l=e*e,y=new m;return y.m11=y.a=1-2*(f+l)*a,y.m12=y.b=2*(t*r*a+e*i*o),y.m13=2*(t*e*a-r*i*o),y.m21=y.c=2*(r*t*a-e*i*o),y.m22=y.d=1-2*(l+s)*a,y.m23=2*(r*e*a+t*i*o),y.m31=2*(e*t*a+r*i*o),y.m32=2*(e*r*a-t*i*o),y.m33=1-2*(s+f)*a,y.m14=y.m24=y.m34=0,y.m41=y.e=y.m42=y.f=y.m43=0,y.m44=1,y},m.Scale=function(t,r,e){var n=new m;return n.m11=n.a=t,n.m22=n.d=r,n.m33=e,n},m.SkewX=function(t){t*=Math.PI/180;var r=new m;return r.m21=r.c=Math.tan(t),r},m.SkewY=function(t){t*=Math.PI/180;var r=new m;return r.m12=r.b=Math.tan(t),r},m.Multiply=function(t,r){var e=r.m11*t.m11+r.m12*t.m21+r.m13*t.m31+r.m14*t.m41,n=r.m11*t.m12+r.m12*t.m22+r.m13*t.m32+r.m14*t.m42,i=r.m11*t.m13+r.m12*t.m23+r.m13*t.m33+r.m14*t.m43,o=r.m11*t.m14+r.m12*t.m24+r.m13*t.m34+r.m14*t.m44,a=r.m21*t.m11+r.m22*t.m21+r.m23*t.m31+r.m24*t.m41,u=r.m21*t.m12+r.m22*t.m22+r.m23*t.m32+r.m24*t.m42,s=r.m21*t.m13+r.m22*t.m23+r.m23*t.m33+r.m24*t.m43,f=r.m21*t.m14+r.m22*t.m24+r.m23*t.m34+r.m24*t.m44,l=r.m31*t.m11+r.m32*t.m21+r.m33*t.m31+r.m34*t.m41,y=r.m31*t.m12+r.m32*t.m22+r.m33*t.m32+r.m34*t.m42,c=r.m31*t.m13+r.m32*t.m23+r.m33*t.m33+r.m34*t.m43,p=r.m31*t.m14+r.m32*t.m24+r.m33*t.m34+r.m34*t.m44,h=r.m41*t.m11+r.m42*t.m21+r.m43*t.m31+r.m44*t.m41,d=r.m41*t.m12+r.m42*t.m22+r.m43*t.m32+r.m44*t.m42,M=r.m41*t.m13+r.m42*t.m23+r.m43*t.m33+r.m44*t.m43,x=r.m41*t.m14+r.m42*t.m24+r.m43*t.m34+r.m44*t.m44;return new m([e,a,l,h,n,u,y,d,i,s,c,M,o,f,p,x])},m.fromMatrix=function(t){return new m([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])},m.fromArray=function(t){return feedFromArray(new m,t)},m.feedFromArray=function(m,t){var r=Array.from(t);if(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];else{if(6!=r.length)throw new TypeError("CSSMatrix: expecting a 6/16 values Array");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]}return m},m}));
{
"name": "dommatrix",
"version": "0.0.4b",
"version": "0.0.4c",
"description": "ES6+ shim for DOMMatrix",

@@ -5,0 +5,0 @@ "main": "dist/dommatrix.min.js",

@@ -16,3 +16,2 @@ # DOMMatrix shim

* *removed* `inverse()` instance method, will be re-added later for other implementations (probably going to be accompanied by `determinant()`, `transpose()` and others);
* *removed* `transform()` instance method, replaced with something that actually works;
* *removed* `toFullString()` instance method, probably something also from *WebKitCSSMatrix*;

@@ -25,3 +24,3 @@ * **added** `is2D` (*getter* and *setter*) property;

* **added** `toArray()`, `toFloat64Array()` and `toFloat32Array()` instance methods, the last two are not present in the constructor prototype;
* **added** `transformPoint()` instance method which works like the original and replaces the old `transform()` method.
* **added** `transformPoint()` instance method which works like the original.

@@ -189,5 +188,13 @@

The `point` parameter expects a vector *Object* with `x`, `y`, `z` and `w` properties or a `DOMPoint`
The `point` parameter expects a `DOMPoint` or an *Object* with `x`, `y`, `z` and `w` components.
**transform(vector)**
Transforms the specified vector using the matrix, returning a new `{x,y,z,w}` *Object* comprising the transformed vector.
Neither the matrix nor the original vector are altered.
The `vector` parameter expects an *Object* with `x`, `y`, `z` and `w` components.
# Additional Methods

@@ -194,0 +201,0 @@

@@ -1,299 +0,4 @@

// Transform Functions
// https://www.w3.org/TR/css-transforms-1/#transform-functions
/**
* Creates a new `CSSMatrix` for the translation matrix and returns it.
* This method is equivalent to the CSS `translate3d()` function.
* DOMMatrix shim - CSSMatrix
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate3d
*
* @param {Number} x the `x-axis` position.
* @param {Number} y the `y-axis` position.
* @param {Number} z the `z-axis` position.
*/
function Translate(x, y, z){
let m = new CSSMatrix();
m.m41 = m.e = x;
m.m42 = m.f = y;
m.m43 = z;
return m
}
/**
* Creates a new `CSSMatrix` for the rotation matrix and returns it.
*
* http://en.wikipedia.org/wiki/Rotation_matrix
*
* @param {Number} rx the `x-axis` rotation.
* @param {Number} ry the `y-axis` rotation.
* @param {Number} rz the `z-axis` rotation.
*/
function Rotate(rx, ry, rz){
let m = new CSSMatrix()
rx *= Math.PI / 180
ry *= Math.PI / 180
rz *= Math.PI / 180
// minus sin() because of right-handed system
let cosx = Math.cos(rx), sinx = -Math.sin(rx),
cosy = Math.cos(ry), siny = -Math.sin(ry),
cosz = Math.cos(rz), sinz = -Math.sin(rz);
m.m11 = m.a = cosy * cosz
m.m12 = m.b = -cosy * sinz
m.m13 = siny
m.m21 = m.c = sinx * siny * cosz + cosx * sinz
m.m22 = m.d = cosx * cosz - sinx * siny * sinz
m.m23 = -sinx * cosy
m.m31 = sinx * sinz - cosx * siny * cosz
m.m32 = sinx * cosz + cosx * siny * sinz
m.m33 = cosx * cosy
return m
}
/**
* Creates a new `CSSMatrix` for the rotation matrix and returns it.
* This method is equivalent to the CSS `rotate3d()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d
*
* @param {Number} x the `x-axis` vector length.
* @param {Number} y the `y-axis` vector length.
* @param {Number} z the `z-axis` vector length.
* @param {Number} angle the value in degrees of the rotation.
*/
function RotateAxisAngle(x, y, z, angle){
angle *= Math.PI / 360;
let sinA = Math.sin(angle),
cosA = Math.cos(angle),
sinA2 = sinA * sinA,
length = Math.sqrt(x * x + y * y + z * z);
if (length === 0){
// bad vector length, use something reasonable
x = 0;
y = 0;
z = 1;
} else {
x /= length;
y /= length;
z /= length;
}
let x2 = x * x, y2 = y * y, z2 = z * z;
let m = new CSSMatrix();
m.m11 = m.a = 1 - 2 * (y2 + z2) * sinA2;
m.m12 = m.b = 2 * (x * y * sinA2 + z * sinA * cosA);
m.m13 = 2 * (x * z * sinA2 - y * sinA * cosA);
m.m21 = m.c = 2 * (y * x * sinA2 - z * sinA * cosA);
m.m22 = m.d = 1 - 2 * (z2 + x2) * sinA2;
m.m23 = 2 * (y * z * sinA2 + x * sinA * cosA);
m.m31 = 2 * (z * x * sinA2 + y * sinA * cosA);
m.m32 = 2 * (z * y * sinA2 - x * sinA * cosA);
m.m33 = 1 - 2 * (x2 + y2) * sinA2;
m.m14 = m.m24 = m.m34 = 0;
m.m41 = m.e = m.m42 = m.f = m.m43 = 0;
m.m44 = 1;
return m
}
/**
* Creates a new `CSSMatrix` for the scale matrix and returns it.
* This method is equivalent to the CSS `scale3d()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale3d
*
* @param {Number} x the `x-axis` scale.
* @param {Number} y the `y-axis` scale.
* @param {Number} z the `z-axis` scale.
*/
function Scale(x, y, z){
let m = new CSSMatrix();
m.m11 = m.a = x;
m.m22 = m.d = y;
m.m33 = z;
return m
}
/**
* Creates a new `CSSMatrix` for the shear of the `x-axis` rotation matrix and
* returns it. This method is equivalent to the CSS `skewX()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewX
*
* @param {Number} angle the angle in degrees.
*/
function SkewX(angle){
angle *= Math.PI / 180;
let m = new CSSMatrix();
m.m21 = m.c = Math.tan(angle);
return m
}
/**
* Creates a new `CSSMatrix` for the shear of the `y-axis` rotation matrix and
* returns it. This method is equivalent to the CSS `skewY()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewY
*
* @param {Number} angle the angle in degrees.
*/
function SkewY(angle){
angle *= Math.PI / 180;
let m = new CSSMatrix();
m.m12 = m.b = Math.tan(angle);
return m
}
/**
* Creates a new `CSSMatrix` resulted from the multiplication of two matrixes
* and returns it. Both matrixes are not changed.
*
* @param {CSSMatrix} m1 the first matrix.
* @param {CSSMatrix} m2 the second matrix.
*/
function Multiply(m1, m2){
let m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41,
m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42,
m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43,
m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44,
m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41,
m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42,
m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43,
m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44,
m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41,
m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42,
m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43,
m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44,
m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41,
m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42,
m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43,
m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44
return new CSSMatrix(
[m11, m21, m31, m41,
m12, m22, m32, m42,
m13, m23, m33, m43,
m14, m24, m34, m44])
}
/**
* Returns a new *Float32Array* containing all 16 elements which comprise the matrix.
* The elements are stored into the array as single-precision floating-point numbers
* in column-major (colexographical access access or "colex") order.
*
* @return {Float32Array} matrix elements (m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44)
*/
// toFloat32Array(){
// return Float32Array.from(this.toArray())
// }
/**
* Returns a new Float64Array containing all 16 elements which comprise the matrix.
* The elements are stored into the array as double-precision floating-point numbers
* in column-major (colexographical access access or "colex") order.
*
* @return {Float64Array} matrix elements (m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44)
*/
// toFloat64Array(){
// return Float64Array.from(this.toArray())
// }
/**
* Creates a new mutable `CSSMatrix` object given an existing matrix or a
* `DOMMatrix` *Object* which provides the values for its properties.
*
* @param {CSSMatrix} CSSMatrix the source `CSSMatrix` / `DOMMatrix` initialization to feed values from
*/
function fromMatrix(m){
return new CSSMatrix(
// DOMMatrix elements order
[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])
}
/**
* Creates a new mutable `CSSMatrix` object given an array float values.
*
* If the array has six values, the result is a 2D matrix; if the array has 16 values,
* the result is a 3D matrix. Otherwise, a TypeError exception is thrown.
*
* @param {Array} array The source `Array` to feed values from.
* @return {CSSMatrix} a The source array to feed values from.
*/
function fromArray(a){
return feedFromArray(new CSSMatrix(),a)
}
/**
* Each create a new mutable `CSSMatrix` object given an array of single/double-precision
* (32/64 bit) floating-point values.
*
* If the array has six values, the result is a 2D matrix; if the array has 16 values,
* the result is a 3D matrix. Otherwise, a TypeError exception is thrown.
*
* @param {Float32Array|Float64Array} array The source `Float32Array` / `Float64Array` to feed values from.
* @return {CSSMatrix} a The source array to feed values from.
*/
// more of an alias for now, will update later if it's the case
// function fromFloat32Array(a){
// return feedFromArray(new CSSMatrix(),a)
// }
// function fromFloat64Array(a){ // more of an alias
// return feedFromArray(new CSSMatrix(),a)
// }
/**
* Feed a CSSMatrix object with the values of a 6/16 values array and returns it.
*
* @param {Array} array The source `Array` to feed values from.
* @return {CSSMatrix} a The source array to feed values from.
*/
function feedFromArray(m,array){
let a = Array.from(array)
if (a.length == 16){
m.m11 = m.a = a[0];
m.m21 = m.c = a[1];
m.m31 = a[2];
m.m41 = m.e = a[3];
m.m12 = m.b = a[4];
m.m22 = m.d = a[5];
m.m32 = a[6];
m.m42 = m.f = a[7];
m.m13 = a[8];
m.m23 = a[9];
m.m33 = a[10];
m.m43 = a[11];
m.m14 = a[12];
m.m24 = a[13];
m.m34 = a[14];
m.m44 = a[15];
} else if (a.length == 6) {
m.m11 = m.a = a[0];
m.m12 = m.b = a[1];
m.m14 = m.e = a[4];
m.m21 = m.c = a[2];
m.m22 = m.d = a[3];
m.m24 = m.f = a[5];
} else {
console.error(`CSSMatrix: expecting a 6/16 values Array`)
}
return m
}
/**
* Creates and returns a new `DOMMatrix` compatible *Object*

@@ -347,3 +52,3 @@ * with equivalent instance methods.

} else {
console.error(`CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax`)
throw new TypeError(`CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax`)
}

@@ -491,4 +196,3 @@ } else if (source[0] instanceof CSSMatrix) { // CSSMatrix instance

if (arguments.length!==4){
console.error(`CSSMatrix: expecting 4 values`)
return this
throw new TypeError(`CSSMatrix: expecting 4 values`)
}

@@ -578,3 +282,3 @@ return Multiply(this,RotateAxisAngle(x, y, z, angle))

* Transforms the specified point using the matrix, returning a new
* `DOMPoint` like *Object* containing the transformed point.
* *Object* containing the transformed point.
* Neither the matrix nor the original point are altered.

@@ -587,4 +291,4 @@ *

*
* @param {Tuple} vector the *Object* with `x`, `y`, `z` and `w` properties
* @return {Tuple} a new `{x,y,z,w}` *Object*
* @param {Point} point the *Object* with `x`, `y`, `z` and `w` components
* @return {Point} a new `{x,y,z,w}` *Object*
*/

@@ -603,15 +307,323 @@ transformPoint(v){

}
}
}
/**
* Transforms the specified vector using the matrix, returning a new
* {x,y,z,w} *Object* comprising the transformed vector.
* Neither the matrix nor the original vector are altered.
*
* @param {Tuple} tupple an object with x, y, z and w components
* @return {Tuple} the passed tuple
*/
transform(t){
let m = this,
x = m.m11 * t.x + m.m12 * t.y + m.m13 * t.z + m.m14 * t.w,
y = m.m21 * t.x + m.m22 * t.y + m.m23 * t.z + m.m24 * t.w,
z = m.m31 * t.x + m.m32 * t.y + m.m33 * t.z + m.m34 * t.w,
w = m.m41 * t.x + m.m42 * t.y + m.m43 * t.z + m.m44 * t.w
return {
x: x / w,
y: y / w,
z: z / w,
w : w
}
}
}
// export Transform Functions and static methods to global
CSSMatrix.Translate = Translate
CSSMatrix.Rotate = Rotate
CSSMatrix.RotateAxisAngle = RotateAxisAngle
CSSMatrix.Scale = Scale
CSSMatrix.SkewX = SkewX
CSSMatrix.SkewY = SkewY
CSSMatrix.Multiply = Multiply
CSSMatrix.fromMatrix = fromMatrix
CSSMatrix.fromArray = fromArray
CSSMatrix.feedFromArray = feedFromArray
// Transform Functions
// https://www.w3.org/TR/css-transforms-1/#transform-functions
/**
* Creates a new `CSSMatrix` for the translation matrix and returns it.
* This method is equivalent to the CSS `translate3d()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate3d
*
* @param {Number} x the `x-axis` position.
* @param {Number} y the `y-axis` position.
* @param {Number} z the `z-axis` position.
*/
CSSMatrix.Translate = function Translate(x, y, z){
let m = new CSSMatrix();
m.m41 = m.e = x;
m.m42 = m.f = y;
m.m43 = z;
return m
}
/**
* Creates a new `CSSMatrix` for the rotation matrix and returns it.
*
* http://en.wikipedia.org/wiki/Rotation_matrix
*
* @param {Number} rx the `x-axis` rotation.
* @param {Number} ry the `y-axis` rotation.
* @param {Number} rz the `z-axis` rotation.
*/
CSSMatrix.Rotate = function Rotate(rx, ry, rz){
let m = new CSSMatrix()
rx *= Math.PI / 180
ry *= Math.PI / 180
rz *= Math.PI / 180
// minus sin() because of right-handed system
let cosx = Math.cos(rx), sinx = -Math.sin(rx),
cosy = Math.cos(ry), siny = -Math.sin(ry),
cosz = Math.cos(rz), sinz = -Math.sin(rz);
m.m11 = m.a = cosy * cosz
m.m12 = m.b = -cosy * sinz
m.m13 = siny
m.m21 = m.c = sinx * siny * cosz + cosx * sinz
m.m22 = m.d = cosx * cosz - sinx * siny * sinz
m.m23 = -sinx * cosy
m.m31 = sinx * sinz - cosx * siny * cosz
m.m32 = sinx * cosz + cosx * siny * sinz
m.m33 = cosx * cosy
return m
}
/**
* Creates a new `CSSMatrix` for the rotation matrix and returns it.
* This method is equivalent to the CSS `rotate3d()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d
*
* @param {Number} x the `x-axis` vector length.
* @param {Number} y the `y-axis` vector length.
* @param {Number} z the `z-axis` vector length.
* @param {Number} angle the value in degrees of the rotation.
*/
CSSMatrix.RotateAxisAngle = function RotateAxisAngle(x, y, z, angle){
angle *= Math.PI / 360;
let sinA = Math.sin(angle),
cosA = Math.cos(angle),
sinA2 = sinA * sinA,
length = Math.sqrt(x * x + y * y + z * z);
if (length === 0){
// bad vector length, use something reasonable
x = 0;
y = 0;
z = 1;
} else {
x /= length;
y /= length;
z /= length;
}
let x2 = x * x, y2 = y * y, z2 = z * z;
let m = new CSSMatrix();
m.m11 = m.a = 1 - 2 * (y2 + z2) * sinA2;
m.m12 = m.b = 2 * (x * y * sinA2 + z * sinA * cosA);
m.m13 = 2 * (x * z * sinA2 - y * sinA * cosA);
m.m21 = m.c = 2 * (y * x * sinA2 - z * sinA * cosA);
m.m22 = m.d = 1 - 2 * (z2 + x2) * sinA2;
m.m23 = 2 * (y * z * sinA2 + x * sinA * cosA);
m.m31 = 2 * (z * x * sinA2 + y * sinA * cosA);
m.m32 = 2 * (z * y * sinA2 - x * sinA * cosA);
m.m33 = 1 - 2 * (x2 + y2) * sinA2;
m.m14 = m.m24 = m.m34 = 0;
m.m41 = m.e = m.m42 = m.f = m.m43 = 0;
m.m44 = 1;
return m
}
/**
* Creates a new `CSSMatrix` for the scale matrix and returns it.
* This method is equivalent to the CSS `scale3d()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale3d
*
* @param {Number} x the `x-axis` scale.
* @param {Number} y the `y-axis` scale.
* @param {Number} z the `z-axis` scale.
*/
CSSMatrix.Scale = function Scale(x, y, z){
let m = new CSSMatrix();
m.m11 = m.a = x;
m.m22 = m.d = y;
m.m33 = z;
return m
}
/**
* Creates a new `CSSMatrix` for the shear of the `x-axis` rotation matrix and
* returns it. This method is equivalent to the CSS `skewX()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewX
*
* @param {Number} angle the angle in degrees.
*/
CSSMatrix.SkewX = function SkewX(angle){
angle *= Math.PI / 180;
let m = new CSSMatrix();
m.m21 = m.c = Math.tan(angle);
return m
}
/**
* Creates a new `CSSMatrix` for the shear of the `y-axis` rotation matrix and
* returns it. This method is equivalent to the CSS `skewY()` function.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewY
*
* @param {Number} angle the angle in degrees.
*/
CSSMatrix.SkewY = function SkewY(angle){
angle *= Math.PI / 180;
let m = new CSSMatrix();
m.m12 = m.b = Math.tan(angle);
return m
}
/**
* Creates a new `CSSMatrix` resulted from the multiplication of two matrixes
* and returns it. Both matrixes are not changed.
*
* @param {CSSMatrix} m1 the first matrix.
* @param {CSSMatrix} m2 the second matrix.
*/
CSSMatrix.Multiply = function Multiply(m1, m2){
let m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41,
m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42,
m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43,
m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44,
m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41,
m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42,
m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43,
m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44,
m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41,
m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42,
m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43,
m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44,
m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41,
m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42,
m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43,
m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44
return new CSSMatrix(
[m11, m21, m31, m41,
m12, m22, m32, m42,
m13, m23, m33, m43,
m14, m24, m34, m44])
}
/**
* Returns a new *Float32Array* containing all 16 elements which comprise the matrix.
* The elements are stored into the array as single-precision floating-point numbers
* in column-major (colexographical access access or "colex") order.
*
* @return {Float32Array} matrix elements (m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44)
*/
// toFloat32Array(){
// return Float32Array.from(this.toArray())
// }
/**
* Returns a new Float64Array containing all 16 elements which comprise the matrix.
* The elements are stored into the array as double-precision floating-point numbers
* in column-major (colexographical access access or "colex") order.
*
* @return {Float64Array} matrix elements (m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44)
*/
// toFloat64Array(){
// return Float64Array.from(this.toArray())
// }
/**
* Creates a new mutable `CSSMatrix` object given an existing matrix or a
* `DOMMatrix` *Object* which provides the values for its properties.
*
* @param {CSSMatrix} CSSMatrix the source `CSSMatrix` / `DOMMatrix` initialization to feed values from
*/
CSSMatrix.fromMatrix = function fromMatrix(m){
return new CSSMatrix(
// DOMMatrix elements order
[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])
}
/**
* Creates a new mutable `CSSMatrix` object given an array float values.
*
* If the array has six values, the result is a 2D matrix; if the array has 16 values,
* the result is a 3D matrix. Otherwise, a TypeError exception is thrown.
*
* @param {Array} array The source `Array` to feed values from.
* @return {CSSMatrix} a The source array to feed values from.
*/
CSSMatrix.fromArray = function fromArray(a){
return feedFromArray(new CSSMatrix(),a)
}
/**
* Each create a new mutable `CSSMatrix` object given an array of single/double-precision
* (32/64 bit) floating-point values.
*
* If the array has six values, the result is a 2D matrix; if the array has 16 values,
* the result is a 3D matrix. Otherwise, a TypeError exception is thrown.
*
* @param {Float32Array|Float64Array} array The source `Float32Array` / `Float64Array` to feed values from.
* @return {CSSMatrix} a The source array to feed values from.
*/
// more of an alias for now, will update later if it's the case
// function fromFloat32Array(a){
// return feedFromArray(new CSSMatrix(),a)
// }
// function fromFloat64Array(a){ // more of an alias
// return feedFromArray(new CSSMatrix(),a)
// }
/**
* Feed a CSSMatrix object with the values of a 6/16 values array and returns it.
*
* @param {Array} array The source `Array` to feed values from.
* @return {CSSMatrix} a The source array to feed values from.
*/
CSSMatrix.feedFromArray = function feedFromArray(m,array){
let a = Array.from(array)
if (a.length == 16){
m.m11 = m.a = a[0];
m.m21 = m.c = a[1];
m.m31 = a[2];
m.m41 = m.e = a[3];
m.m12 = m.b = a[4];
m.m22 = m.d = a[5];
m.m32 = a[6];
m.m42 = m.f = a[7];
m.m13 = a[8];
m.m23 = a[9];
m.m33 = a[10];
m.m43 = a[11];
m.m14 = a[12];
m.m24 = a[13];
m.m34 = a[14];
m.m44 = a[15];
} else if (a.length == 6) {
m.m11 = m.a = a[0];
m.m12 = m.b = a[1];
m.m14 = m.e = a[4];
m.m21 = m.c = a[2];
m.m22 = m.d = a[3];
m.m24 = m.f = a[5];
} else {
throw new TypeError(`CSSMatrix: expecting a 6/16 values Array`)
}
return m
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc