Comparing version 0.0.5-alpha2 to 0.0.6
/*! | ||
* DOMMatrix v0.0.5-alpha2 (https://github.com/thednp/dommatrix) | ||
* DOMMatrix v0.0.6 (https://github.com/thednp/dommatrix) | ||
* Copyright 2021 © thednp | ||
@@ -21,60 +21,55 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE) | ||
var CSSMatrix = function CSSMatrix() { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
class CSSMatrix { | ||
constructor(...args) { | ||
this.setIdentity(); | ||
return args && args.length && this.setMatrixValue(args); | ||
} | ||
this.setIdentity(); | ||
return args && args.length && this.setMatrixValue(args); | ||
}; | ||
/** | ||
* A `Boolean` whose value is `true` if the matrix is the identity matrix. The identity | ||
* matrix is one in which every value is 0 except those on the main diagonal from top-left | ||
* to bottom-right corner (in other words, where the offsets in each direction are equal). | ||
* | ||
* @return {Boolean} `Boolean` the current property value | ||
*/ | ||
get isIdentity() { | ||
const 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); | ||
} | ||
var prototypeAccessors = { isIdentity: { configurable: true },is2D: { configurable: true } }; | ||
/** | ||
* Sets a new `Boolean` flag value for `this.isIdentity` matrix property. | ||
* | ||
* @param {Boolean} value sets a new `Boolean` flag for this property | ||
*/ | ||
set isIdentity(value) { | ||
this.isIdentity = value; | ||
} | ||
/** | ||
* A `Boolean` whose value is `true` if the matrix is the identity matrix. The identity | ||
* matrix is one in which every value is 0 except those on the main diagonal from top-left | ||
* to bottom-right corner (in other words, where the offsets in each direction are equal). | ||
* | ||
* @return {Boolean} `Boolean` the current property value | ||
*/ | ||
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); | ||
}; | ||
/** | ||
* A `Boolean` flag whose value is `true` if the matrix was initialized as a 2D matrix | ||
* and `false` if the matrix is 3D. | ||
* | ||
* @return {Boolean} `Boolean` the current property value | ||
*/ | ||
get is2D() { | ||
const m = this; | ||
return (m.m31 === 0 && m.m32 === 0 && m.m33 === 1 && m.m34 === 0 && m.m43 === 0 && m.m44 === 1); | ||
} | ||
/** | ||
* Sets a new `Boolean` flag value for `this.isIdentity` matrix property. | ||
* | ||
* @param {Boolean} value sets a new `Boolean` flag for this property | ||
*/ | ||
prototypeAccessors.isIdentity.set = function (value) { | ||
this.isIdentity = value; | ||
}; | ||
/** | ||
* Sets a new `Boolean` flag value for `this.is2D` matrix property. | ||
* | ||
* @param {Boolean} value sets a new `Boolean` flag for this property | ||
*/ | ||
set is2D(value) { | ||
this.is2D = value; | ||
} | ||
} | ||
/** | ||
* A `Boolean` flag whose value is `true` if the matrix was initialized as a 2D matrix | ||
* and `false` if the matrix is 3D. | ||
* | ||
* @return {Boolean} `Boolean` the current property 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); | ||
}; | ||
/** | ||
* Sets a new `Boolean` flag value for `this.is2D` matrix property. | ||
* | ||
* @param {Boolean} value sets a new `Boolean` flag for this property | ||
*/ | ||
prototypeAccessors.is2D.set = function (value) { | ||
this.is2D = value; | ||
}; | ||
Object.defineProperties( CSSMatrix.prototype, prototypeAccessors ); | ||
// export proto for custom compile via Buble | ||
var CSSMatrixProto = CSSMatrix.prototype; | ||
const CSSMatrixProto = CSSMatrix.prototype; | ||
@@ -95,3 +90,3 @@ // Transform Functions | ||
function Translate(x, y, z) { | ||
var m = new CSSMatrix(); | ||
const m = new CSSMatrix(); | ||
m.m41 = x; | ||
@@ -116,18 +111,18 @@ m.e = x; | ||
function Rotate(rx, ry, rz) { | ||
var m = new CSSMatrix(); | ||
const m = new CSSMatrix(); | ||
var radX = (rx * Math.PI) / 180; | ||
var radY = (ry * Math.PI) / 180; | ||
var radZ = (rz * Math.PI) / 180; | ||
const radX = (rx * Math.PI) / 180; | ||
const radY = (ry * Math.PI) / 180; | ||
const radZ = (rz * Math.PI) / 180; | ||
// minus sin() because of right-handed system | ||
var cosx = Math.cos(radX); | ||
var sinx = -Math.sin(radX); | ||
var cosy = Math.cos(radY); | ||
var siny = -Math.sin(radY); | ||
var cosz = Math.cos(radZ); | ||
var sinz = -Math.sin(radZ); | ||
const cosx = Math.cos(radX); | ||
const sinx = -Math.sin(radX); | ||
const cosy = Math.cos(radY); | ||
const siny = -Math.sin(radY); | ||
const cosz = Math.cos(radZ); | ||
const sinz = -Math.sin(radZ); | ||
var cycz = cosy * cosz; | ||
var cysz = -cosy * sinz; | ||
const cycz = cosy * cosz; | ||
const cysz = -cosy * sinz; | ||
@@ -142,7 +137,7 @@ m.m11 = cycz; | ||
var sxsy = sinx * siny * cosz + cosx * sinz; | ||
const sxsy = sinx * siny * cosz + cosx * sinz; | ||
m.m21 = sxsy; | ||
m.c = sxsy; | ||
var cxcz = cosx * cosz - sinx * siny * sinz; | ||
const cxcz = cosx * cosz - sinx * siny * sinz; | ||
m.m22 = cxcz; | ||
@@ -172,11 +167,11 @@ m.d = cxcz; | ||
function RotateAxisAngle(x, y, z, angle) { | ||
var m = new CSSMatrix(); | ||
var radA = (angle * Math.PI) / 360; | ||
var sinA = Math.sin(radA); | ||
var cosA = Math.cos(radA); | ||
var sinA2 = sinA * sinA; | ||
var length = Math.sqrt(x * x + y * y + z * z); | ||
var X = 0; | ||
var Y = 0; | ||
var Z = 1; | ||
const m = new CSSMatrix(); | ||
const radA = (angle * Math.PI) / 360; | ||
const sinA = Math.sin(radA); | ||
const cosA = Math.cos(radA); | ||
const sinA2 = sinA * sinA; | ||
const length = Math.sqrt(x * x + y * y + z * z); | ||
let X = 0; | ||
let Y = 0; | ||
let Z = 1; | ||
@@ -190,11 +185,11 @@ // bad vector length, use something reasonable | ||
var x2 = X * X; | ||
var y2 = Y * Y; | ||
var z2 = Z * Z; | ||
const x2 = X * X; | ||
const y2 = Y * Y; | ||
const z2 = Z * Z; | ||
var m11 = 1 - 2 * (y2 + z2) * sinA2; | ||
const m11 = 1 - 2 * (y2 + z2) * sinA2; | ||
m.m11 = m11; | ||
m.a = m11; | ||
var m12 = 2 * (x * y * sinA2 + z * sinA * cosA); | ||
const m12 = 2 * (x * y * sinA2 + z * sinA * cosA); | ||
m.m12 = m12; | ||
@@ -205,7 +200,7 @@ m.b = m12; | ||
var m21 = 2 * (y * x * sinA2 - z * sinA * cosA); | ||
const m21 = 2 * (y * x * sinA2 - z * sinA * cosA); | ||
m.m21 = m21; | ||
m.c = m21; | ||
var m22 = 1 - 2 * (z2 + x2) * sinA2; | ||
const m22 = 1 - 2 * (z2 + x2) * sinA2; | ||
m.m22 = m22; | ||
@@ -245,3 +240,3 @@ m.d = m22; | ||
function Scale(x, y, z) { | ||
var m = new CSSMatrix(); | ||
const m = new CSSMatrix(); | ||
m.m11 = x; | ||
@@ -266,5 +261,5 @@ m.a = x; | ||
function SkewX(angle) { | ||
var radA = (angle * Math.PI) / 180; | ||
var m = new CSSMatrix(); | ||
var t = Math.tan(radA); | ||
const radA = (angle * Math.PI) / 180; | ||
const m = new CSSMatrix(); | ||
const t = Math.tan(radA); | ||
m.m21 = t; | ||
@@ -284,5 +279,5 @@ m.c = t; | ||
function SkewY(angle) { | ||
var radA = (angle * Math.PI) / 180; | ||
var m = new CSSMatrix(); | ||
var t = Math.tan(radA); | ||
const radA = (angle * Math.PI) / 180; | ||
const m = new CSSMatrix(); | ||
const t = Math.tan(radA); | ||
m.m12 = t; | ||
@@ -301,21 +296,21 @@ m.b = t; | ||
function Multiply(m1, m2) { | ||
var m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41; | ||
var m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42; | ||
var m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43; | ||
var m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44; | ||
const m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41; | ||
const m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42; | ||
const m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43; | ||
const m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44; | ||
var m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41; | ||
var m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42; | ||
var m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43; | ||
var m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44; | ||
const m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41; | ||
const m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42; | ||
const m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43; | ||
const m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44; | ||
var m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41; | ||
var m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42; | ||
var m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43; | ||
var m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44; | ||
const m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41; | ||
const m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42; | ||
const m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43; | ||
const m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44; | ||
var m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41; | ||
var m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42; | ||
var m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43; | ||
var m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44; | ||
const m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41; | ||
const m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42; | ||
const m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43; | ||
const m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44; | ||
@@ -326,3 +321,3 @@ return new CSSMatrix( | ||
m13, m23, m33, m43, | ||
m14, m24, m34, m44] | ||
m14, m24, m34, m44], | ||
); | ||
@@ -365,3 +360,3 @@ } | ||
m.m13, m.m23, m.m33, m.m43, | ||
m.m14, m.m24, m.m34, m.m44] | ||
m.m14, m.m24, m.m34, m.m44], | ||
); | ||
@@ -377,20 +372,8 @@ } | ||
function feedFromArray(m, array) { | ||
var a = Array.from(array); | ||
const a = Array.from(array); | ||
if (a.length === 16) { | ||
var m11 = a[0]; | ||
var m21 = a[1]; | ||
var m31 = a[2]; | ||
var m41 = a[3]; | ||
var m12 = a[4]; | ||
var m22 = a[5]; | ||
var m32 = a[6]; | ||
var m42 = a[7]; | ||
var m13 = a[8]; | ||
var m23 = a[9]; | ||
var m33 = a[10]; | ||
var m43 = a[11]; | ||
var m14 = a[12]; | ||
var m24 = a[13]; | ||
var m34 = a[14]; | ||
var m44 = a[15]; | ||
const [m11, m21, m31, m41, | ||
m12, m22, m32, m42, | ||
m13, m23, m33, m43, | ||
m14, m24, m34, m44] = a; | ||
@@ -428,26 +411,21 @@ m.m11 = m11; | ||
} else if (a.length === 6) { | ||
var m11$1 = a[0]; | ||
var m12$1 = a[1]; | ||
var m21$1 = a[2]; | ||
var m22$1 = a[3]; | ||
var m14$1 = a[4]; | ||
var m24$1 = a[5]; | ||
const [m11, m12, m21, m22, m14, m24] = a; | ||
m.m11 = m11$1; | ||
m.a = m11$1; | ||
m.m11 = m11; | ||
m.a = m11; | ||
m.m12 = m12$1; | ||
m.b = m12$1; | ||
m.m12 = m12; | ||
m.b = m12; | ||
m.m21 = m21$1; | ||
m.c = m21$1; | ||
m.m21 = m21; | ||
m.c = m21; | ||
m.m22 = m22$1; | ||
m.d = m22$1; | ||
m.m22 = m22; | ||
m.d = m22; | ||
m.m14 = m14$1; | ||
m.e = m14$1; | ||
m.m14 = m14; | ||
m.e = m14; | ||
m.m24 = m24$1; | ||
m.f = m24$1; | ||
m.m24 = m24; | ||
m.f = m24; | ||
} else { | ||
@@ -504,3 +482,3 @@ throw new TypeError('CSSMatrix: expecting a 6/16 values Array'); | ||
CSSMatrixProto.setMatrixValue = function setMatrixValue(source) { | ||
var m = this; | ||
const m = this; | ||
@@ -510,11 +488,11 @@ if (!source || !source.length) { // no parameters or source | ||
} if (source.length && typeof source[0] === 'string' && source[0].length) { // CSS transform String source | ||
var string = String(source[0]).trim(); | ||
var type = ''; | ||
var values = []; | ||
const string = String(source[0]).trim(); | ||
let type = ''; | ||
let values = []; | ||
if (string === 'none') { return m; } | ||
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); }); | ||
.map((n) => (Math.abs(n) < 1e-6 ? 0 : +n)); | ||
@@ -548,6 +526,6 @@ if ([6, 16].indexOf(values.length) > -1) { | ||
CSSMatrixProto.toString = function toString() { | ||
var m = this; | ||
var type = m.is2D ? 'matrix' : 'matrix3d'; | ||
const m = this; | ||
const type = m.is2D ? 'matrix' : 'matrix3d'; | ||
return (type + "(" + (m.toArray(1).join(',')) + ")"); | ||
return `${type}(${m.toArray(1).join(',')})`; | ||
}; | ||
@@ -566,4 +544,4 @@ | ||
CSSMatrixProto.toArray = function toArray(transposed) { | ||
var m = this; | ||
var result; | ||
const m = this; | ||
let result; | ||
@@ -620,7 +598,7 @@ if (m.is2D) { | ||
CSSMatrixProto.translate = function translate(x, y, z) { | ||
var X = x; | ||
var Y = y; | ||
var Z = z; | ||
if (Z == null) { Z = 0; } | ||
if (Y == null) { Y = 0; } | ||
const X = x; | ||
let Y = y; | ||
let Z = z; | ||
if (Z == null) Z = 0; | ||
if (Y == null) Y = 0; | ||
return Multiply(this, Translate(X, Y, Z)); | ||
@@ -641,7 +619,7 @@ }; | ||
CSSMatrixProto.scale = function scale(x, y, z) { | ||
var X = x; | ||
var Y = y; | ||
var Z = z; | ||
if (Y == null) { Y = x; } | ||
if (Z == null) { Z = x; } | ||
const X = x; | ||
let Y = y; | ||
let Z = z; | ||
if (Y == null) Y = x; | ||
if (Z == null) Z = x; | ||
@@ -664,6 +642,6 @@ return Multiply(this, Scale(X, Y, Z)); | ||
CSSMatrixProto.rotate = function rotate(rx, ry, rz) { | ||
var RX = rx; | ||
var RY = ry; | ||
var RZ = rz; | ||
if (RY == null) { RY = 0; } | ||
let RX = rx; | ||
let RY = ry; | ||
let RZ = rz; | ||
if (RY == null) RY = 0; | ||
if (RZ == null) { RZ = RX; RX = 0; } | ||
@@ -723,3 +701,3 @@ return Multiply(this, Rotate(RX, RY, RZ)); | ||
CSSMatrixProto.setIdentity = function setIdentity() { | ||
var identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; | ||
const identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; | ||
return feedFromArray(this, identity); | ||
@@ -742,4 +720,4 @@ }; | ||
CSSMatrixProto.transformPoint = function transformPoint(v) { | ||
var M = this; | ||
var m = Translate(v.x, v.y, v.z); | ||
const M = this; | ||
let m = Translate(v.x, v.y, v.z); | ||
@@ -766,7 +744,7 @@ m.m44 = v.w || 1; | ||
CSSMatrixProto.transform = function transform(t) { | ||
var m = this; | ||
var x = m.m11 * t.x + m.m12 * t.y + m.m13 * t.z + m.m14 * t.w; | ||
var y = m.m21 * t.x + m.m22 * t.y + m.m23 * t.z + m.m24 * t.w; | ||
var z = m.m31 * t.x + m.m32 * t.y + m.m33 * t.z + m.m34 * t.w; | ||
var w = m.m41 * t.x + m.m42 * t.y + m.m43 * t.z + m.m44 * t.w; | ||
const m = this; | ||
const x = m.m11 * t.x + m.m12 * t.y + m.m13 * t.z + m.m14 * t.w; | ||
const y = m.m21 * t.x + m.m22 * t.y + m.m23 * t.z + m.m24 * t.w; | ||
const z = m.m31 * t.x + m.m32 * t.y + m.m33 * t.z + m.m34 * t.w; | ||
const w = m.m41 * t.x + m.m42 * t.y + m.m43 * t.z + m.m44 * t.w; | ||
@@ -777,3 +755,3 @@ return { | ||
z: z / w, | ||
w: w, | ||
w, | ||
}; | ||
@@ -780,0 +758,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
// DOMMatrix v0.0.5-alpha2 | thednp © 2021 | 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}};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},Object.defineProperties(m.prototype,t);var r=m.prototype;function n(t,r,n){var e=new m;return e.m41=t,e.e=t,e.m42=r,e.f=r,e.m43=n,e}function e(t,r,n){var e=new m,i=t*Math.PI/180,a=r*Math.PI/180,u=n*Math.PI/180,s=Math.cos(i),o=-Math.sin(i),f=Math.cos(a),c=-Math.sin(a),h=Math.cos(u),l=-Math.sin(u),y=f*h,v=-f*l;e.m11=y,e.a=y,e.m12=v,e.b=v,e.m13=c;var x=o*c*h+s*l;e.m21=x,e.c=x;var w=s*h-o*c*l;return e.m22=w,e.d=w,e.m23=-o*f,e.m31=o*l-s*c*h,e.m32=o*h+s*c*l,e.m33=s*f,e}function i(t,r,n,e){var i=new m,a=e*Math.PI/360,u=Math.sin(a),s=Math.cos(a),o=u*u,f=Math.sqrt(t*t+r*r+n*n),c=0,h=0,l=1;0!==f&&(c=t/f,h=r/f,l=n/f);var y=c*c,v=h*h,x=l*l,w=1-2*(v+x)*o;i.m11=w,i.a=w;var M=2*(t*r*o+n*u*s);i.m12=M,i.b=M,i.m13=2*(t*n*o-r*u*s);var g=2*(r*t*o-n*u*s);i.m21=g,i.c=g;var d=1-2*(x+y)*o;return i.m22=d,i.d=d,i.m23=2*(r*n*o+t*u*s),i.m31=2*(n*t*o+r*u*s),i.m32=2*(n*r*o-t*u*s),i.m33=1-2*(y+v)*o,i.m14=0,i.m24=0,i.m34=0,i.m41=0,i.e=0,i.m42=0,i.f=0,i.m43=0,i.m44=1,i}function a(t,r,n){var e=new m;return e.m11=t,e.a=t,e.m22=r,e.d=r,e.m33=n,e}function u(t){var r=t*Math.PI/180,n=new m,e=Math.tan(r);return n.m21=e,n.c=e,n}function s(t){var r=t*Math.PI/180,n=new m,e=Math.tan(r);return n.m12=e,n.b=e,n}function o(t,r){var n=r.m11*t.m11+r.m12*t.m21+r.m13*t.m31+r.m14*t.m41,e=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,u=r.m21*t.m11+r.m22*t.m21+r.m23*t.m31+r.m24*t.m41,s=r.m21*t.m12+r.m22*t.m22+r.m23*t.m32+r.m24*t.m42,o=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,c=r.m31*t.m11+r.m32*t.m21+r.m33*t.m31+r.m34*t.m41,h=r.m31*t.m12+r.m32*t.m22+r.m33*t.m32+r.m34*t.m42,l=r.m31*t.m13+r.m32*t.m23+r.m33*t.m33+r.m34*t.m43,y=r.m31*t.m14+r.m32*t.m24+r.m33*t.m34+r.m34*t.m44,v=r.m41*t.m11+r.m42*t.m21+r.m43*t.m31+r.m44*t.m41,x=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,M=r.m41*t.m14+r.m42*t.m24+r.m43*t.m34+r.m44*t.m44;return new m([n,u,c,v,e,s,h,x,i,o,l,w,a,f,y,M])}function f(m,t){var r=Array.from(t);if(16===r.length){var n=r[0],e=r[1],i=r[2],a=r[3],u=r[4],s=r[5],o=r[6],f=r[7],c=r[8],h=r[9],l=r[10],y=r[11],v=r[12],x=r[13],w=r[14],M=r[15];m.m11=n,m.a=n,m.m21=e,m.c=e,m.m31=i,m.m41=a,m.e=a,m.m12=u,m.b=u,m.m22=s,m.d=s,m.m32=o,m.m42=f,m.f=f,m.m13=c,m.m23=h,m.m33=l,m.m43=y,m.m14=v,m.m24=x,m.m34=w,m.m44=M}else{if(6!==r.length)throw new TypeError("CSSMatrix: expecting a 6/16 values Array");var g=r[0],d=r[1],p=r[2],A=r[3],S=r[4],I=r[5];m.m11=g,m.a=g,m.m12=d,m.b=d,m.m21=p,m.c=p,m.m22=A,m.d=A,m.m14=S,m.e=S,m.m24=I,m.f=I}return m}r.setMatrixValue=function(t){var r=this;if(!t||!t.length)return r;if(t.length&&"string"==typeof t[0]&&t[0].length){var n,e,i=String(t[0]).trim();if("none"===i)return r;if(n=i.slice(0,i.indexOf("(")),e=i.slice("matrix"===n?7:9,-1).split(",").map((function(m){return Math.abs(m)<1e-6?0:+m})),!([6,16].indexOf(e.length)>-1))throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");f(r,e)}else t[0]instanceof m?f(r,t[0].toArray()):Array.isArray(t[0])?f(r,t[0]):Array.isArray(t)&&f(r,t);return r},r.toString=function(){return(this.is2D?"matrix":"matrix3d")+"("+this.toArray(1).join(",")+")"},r.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]},r.multiply=function(m){return o(this,m)},r.translate=function(m,t,r){var e=t,i=r;return null==i&&(i=0),null==e&&(e=0),o(this,n(m,e,i))},r.scale=function(m,t,r){var n=t,e=r;return null==n&&(n=m),null==e&&(e=m),o(this,a(m,n,e))},r.rotate=function(m,t,r){var n=m,i=t,a=r;return null==i&&(i=0),null==a&&(a=n,n=0),o(this,e(n,i,a))},r.rotateAxisAngle=function(m,t,r,n){if(4!==arguments.length)throw new TypeError("CSSMatrix: expecting 4 values");return o(this,i(m,t,r,n))},r.skewX=function(m){return o(this,u(m))},r.skewY=function(m){return o(this,s(m))},r.setIdentity=function(){return f(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},r.transformPoint=function(m){var t=n(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}},r.transform=function(m){var t=this,r=t.m11*m.x+t.m12*m.y+t.m13*m.z+t.m14*m.w,n=t.m21*m.x+t.m22*m.y+t.m23*m.z+t.m24*m.w,e=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:n/i,z:e/i,w:i}},m.Translate=n,m.Rotate=e,m.RotateAxisAngle=i,m.Scale=a,m.SkewX=u,m.SkewY=s,m.Multiply=o,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 f(new m,t)},m.feedFromArray=f;export default m; | ||
// DOMMatrix v0.0.6 | thednp © 2021 | MIT-License | ||
class m{constructor(...m){return this.setIdentity(),m&&m.length&&this.setMatrixValue(m)}get isIdentity(){const 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}set isIdentity(m){this.isIdentity=m}get is2D(){const m=this;return 0===m.m31&&0===m.m32&&1===m.m33&&0===m.m34&&0===m.m43&&1===m.m44}set is2D(m){this.is2D=m}}const t=m.prototype;function n(t,n,r){const e=new m;return e.m41=t,e.e=t,e.m42=n,e.f=n,e.m43=r,e}function r(t,n,r){const e=new m,i=t*Math.PI/180,s=n*Math.PI/180,o=r*Math.PI/180,a=Math.cos(i),c=-Math.sin(i),u=Math.cos(s),l=-Math.sin(s),h=Math.cos(o),f=-Math.sin(o),y=u*h,x=-u*f;e.m11=y,e.a=y,e.m12=x,e.b=x,e.m13=l;const w=c*l*h+a*f;e.m21=w,e.c=w;const M=a*h-c*l*f;return e.m22=M,e.d=M,e.m23=-c*u,e.m31=c*f-a*l*h,e.m32=c*h+a*l*f,e.m33=a*u,e}function e(t,n,r,e){const i=new m,s=e*Math.PI/360,o=Math.sin(s),a=Math.cos(s),c=o*o,u=Math.sqrt(t*t+n*n+r*r);let l=0,h=0,f=1;0!==u&&(l=t/u,h=n/u,f=r/u);const y=l*l,x=h*h,w=f*f,M=1-2*(x+w)*c;i.m11=M,i.a=M;const d=2*(t*n*c+r*o*a);i.m12=d,i.b=d,i.m13=2*(t*r*c-n*o*a);const g=2*(n*t*c-r*o*a);i.m21=g,i.c=g;const p=1-2*(w+y)*c;return i.m22=p,i.d=p,i.m23=2*(n*r*c+t*o*a),i.m31=2*(r*t*c+n*o*a),i.m32=2*(r*n*c-t*o*a),i.m33=1-2*(y+x)*c,i.m14=0,i.m24=0,i.m34=0,i.m41=0,i.e=0,i.m42=0,i.f=0,i.m43=0,i.m44=1,i}function i(t,n,r){const e=new m;return e.m11=t,e.a=t,e.m22=n,e.d=n,e.m33=r,e}function s(t){const n=t*Math.PI/180,r=new m,e=Math.tan(n);return r.m21=e,r.c=e,r}function o(t){const n=t*Math.PI/180,r=new m,e=Math.tan(n);return r.m12=e,r.b=e,r}function a(t,n){const r=n.m11*t.m11+n.m12*t.m21+n.m13*t.m31+n.m14*t.m41,e=n.m11*t.m12+n.m12*t.m22+n.m13*t.m32+n.m14*t.m42,i=n.m11*t.m13+n.m12*t.m23+n.m13*t.m33+n.m14*t.m43,s=n.m11*t.m14+n.m12*t.m24+n.m13*t.m34+n.m14*t.m44,o=n.m21*t.m11+n.m22*t.m21+n.m23*t.m31+n.m24*t.m41,a=n.m21*t.m12+n.m22*t.m22+n.m23*t.m32+n.m24*t.m42,c=n.m21*t.m13+n.m22*t.m23+n.m23*t.m33+n.m24*t.m43,u=n.m21*t.m14+n.m22*t.m24+n.m23*t.m34+n.m24*t.m44,l=n.m31*t.m11+n.m32*t.m21+n.m33*t.m31+n.m34*t.m41,h=n.m31*t.m12+n.m32*t.m22+n.m33*t.m32+n.m34*t.m42,f=n.m31*t.m13+n.m32*t.m23+n.m33*t.m33+n.m34*t.m43,y=n.m31*t.m14+n.m32*t.m24+n.m33*t.m34+n.m34*t.m44,x=n.m41*t.m11+n.m42*t.m21+n.m43*t.m31+n.m44*t.m41,w=n.m41*t.m12+n.m42*t.m22+n.m43*t.m32+n.m44*t.m42,M=n.m41*t.m13+n.m42*t.m23+n.m43*t.m33+n.m44*t.m43,d=n.m41*t.m14+n.m42*t.m24+n.m43*t.m34+n.m44*t.m44;return new m([r,o,l,x,e,a,h,w,i,c,f,M,s,u,y,d])}function c(m,t){const n=Array.from(t);if(16===n.length){const[t,r,e,i,s,o,a,c,u,l,h,f,y,x,w,M]=n;m.m11=t,m.a=t,m.m21=r,m.c=r,m.m31=e,m.m41=i,m.e=i,m.m12=s,m.b=s,m.m22=o,m.d=o,m.m32=a,m.m42=c,m.f=c,m.m13=u,m.m23=l,m.m33=h,m.m43=f,m.m14=y,m.m24=x,m.m34=w,m.m44=M}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting a 6/16 values Array");{const[t,r,e,i,s,o]=n;m.m11=t,m.a=t,m.m12=r,m.b=r,m.m21=e,m.c=e,m.m22=i,m.d=i,m.m14=s,m.e=s,m.m24=o,m.f=o}}return m}t.setMatrixValue=function(t){const n=this;if(!t||!t.length)return n;if(t.length&&"string"==typeof t[0]&&t[0].length){const m=String(t[0]).trim();let r="",e=[];if("none"===m)return n;if(r=m.slice(0,m.indexOf("(")),e=m.slice("matrix"===r?7:9,-1).split(",").map(m=>Math.abs(m)<1e-6?0:+m),!([6,16].indexOf(e.length)>-1))throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");c(n,e)}else t[0]instanceof m?c(n,t[0].toArray()):Array.isArray(t[0])?c(n,t[0]):Array.isArray(t)&&c(n,t);return n},t.toString=function(){return`${this.is2D?"matrix":"matrix3d"}(${this.toArray(1).join(",")})`},t.toArray=function(m){const t=this;let n;return n=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],n},t.multiply=function(m){return a(this,m)},t.translate=function(m,t,r){let e=t,i=r;return null==i&&(i=0),null==e&&(e=0),a(this,n(m,e,i))},t.scale=function(m,t,n){let r=t,e=n;return null==r&&(r=m),null==e&&(e=m),a(this,i(m,r,e))},t.rotate=function(m,t,n){let e=m,i=t,s=n;return null==i&&(i=0),null==s&&(s=e,e=0),a(this,r(e,i,s))},t.rotateAxisAngle=function(m,t,n,r){if(4!==arguments.length)throw new TypeError("CSSMatrix: expecting 4 values");return a(this,e(m,t,n,r))},t.skewX=function(m){return a(this,s(m))},t.skewY=function(m){return a(this,o(m))},t.setIdentity=function(){return c(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},t.transformPoint=function(m){let t=n(m.x,m.y,m.z);return t.m44=m.w||1,t=this.multiply(t),{x:t.m41,y:t.m42,z:t.m43,w:t.m44}},t.transform=function(m){const t=this,n=t.m11*m.x+t.m12*m.y+t.m13*m.z+t.m14*m.w,r=t.m21*m.x+t.m22*m.y+t.m23*m.z+t.m24*m.w,e=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:n/i,y:r/i,z:e/i,w:i}},m.Translate=n,m.Rotate=r,m.RotateAxisAngle=e,m.Scale=i,m.SkewX=s,m.SkewY=o,m.Multiply=a,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 c(new m,t)},m.feedFromArray=c;export default m; |
/*! | ||
* DOMMatrix v0.0.5-alpha2 (https://github.com/thednp/dommatrix) | ||
* DOMMatrix v0.0.6 (https://github.com/thednp/dommatrix) | ||
* Copyright 2021 © thednp | ||
@@ -4,0 +4,0 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE) |
@@ -1,2 +0,2 @@ | ||
// DOMMatrix v0.0.5-alpha2 | thednp © 2021 | MIT-License | ||
// DOMMatrix v0.0.6 | thednp © 2021 | 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}};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},Object.defineProperties(m.prototype,t);var n=m.prototype;function r(t,n,r){var e=new m;return e.m41=t,e.e=t,e.m42=n,e.f=n,e.m43=r,e}function e(t,n,r){var e=new m,i=t*Math.PI/180,a=n*Math.PI/180,u=r*Math.PI/180,o=Math.cos(i),s=-Math.sin(i),f=Math.cos(a),c=-Math.sin(a),h=Math.cos(u),l=-Math.sin(u),y=f*h,v=-f*l;e.m11=y,e.a=y,e.m12=v,e.b=v,e.m13=c;var d=s*c*h+o*l;e.m21=d,e.c=d;var x=o*h-s*c*l;return e.m22=x,e.d=x,e.m23=-s*f,e.m31=s*l-o*c*h,e.m32=s*h+o*c*l,e.m33=o*f,e}function i(t,n,r,e){var i=new m,a=e*Math.PI/360,u=Math.sin(a),o=Math.cos(a),s=u*u,f=Math.sqrt(t*t+n*n+r*r),c=0,h=0,l=1;0!==f&&(c=t/f,h=n/f,l=r/f);var y=c*c,v=h*h,d=l*l,x=1-2*(v+d)*s;i.m11=x,i.a=x;var w=2*(t*n*s+r*u*o);i.m12=w,i.b=w,i.m13=2*(t*r*s-n*u*o);var M=2*(n*t*s-r*u*o);i.m21=M,i.c=M;var g=1-2*(d+y)*s;return i.m22=g,i.d=g,i.m23=2*(n*r*s+t*u*o),i.m31=2*(r*t*s+n*u*o),i.m32=2*(r*n*s-t*u*o),i.m33=1-2*(y+v)*s,i.m14=0,i.m24=0,i.m34=0,i.m41=0,i.e=0,i.m42=0,i.f=0,i.m43=0,i.m44=1,i}function a(t,n,r){var e=new m;return e.m11=t,e.a=t,e.m22=n,e.d=n,e.m33=r,e}function u(t){var n=t*Math.PI/180,r=new m,e=Math.tan(n);return r.m21=e,r.c=e,r}function o(t){var n=t*Math.PI/180,r=new m,e=Math.tan(n);return r.m12=e,r.b=e,r}function s(t,n){var r=n.m11*t.m11+n.m12*t.m21+n.m13*t.m31+n.m14*t.m41,e=n.m11*t.m12+n.m12*t.m22+n.m13*t.m32+n.m14*t.m42,i=n.m11*t.m13+n.m12*t.m23+n.m13*t.m33+n.m14*t.m43,a=n.m11*t.m14+n.m12*t.m24+n.m13*t.m34+n.m14*t.m44,u=n.m21*t.m11+n.m22*t.m21+n.m23*t.m31+n.m24*t.m41,o=n.m21*t.m12+n.m22*t.m22+n.m23*t.m32+n.m24*t.m42,s=n.m21*t.m13+n.m22*t.m23+n.m23*t.m33+n.m24*t.m43,f=n.m21*t.m14+n.m22*t.m24+n.m23*t.m34+n.m24*t.m44,c=n.m31*t.m11+n.m32*t.m21+n.m33*t.m31+n.m34*t.m41,h=n.m31*t.m12+n.m32*t.m22+n.m33*t.m32+n.m34*t.m42,l=n.m31*t.m13+n.m32*t.m23+n.m33*t.m33+n.m34*t.m43,y=n.m31*t.m14+n.m32*t.m24+n.m33*t.m34+n.m34*t.m44,v=n.m41*t.m11+n.m42*t.m21+n.m43*t.m31+n.m44*t.m41,d=n.m41*t.m12+n.m42*t.m22+n.m43*t.m32+n.m44*t.m42,x=n.m41*t.m13+n.m42*t.m23+n.m43*t.m33+n.m44*t.m43,w=n.m41*t.m14+n.m42*t.m24+n.m43*t.m34+n.m44*t.m44;return new m([r,u,c,v,e,o,h,d,i,s,l,x,a,f,y,w])}function f(m,t){var n=Array.from(t);if(16===n.length){var r=n[0],e=n[1],i=n[2],a=n[3],u=n[4],o=n[5],s=n[6],f=n[7],c=n[8],h=n[9],l=n[10],y=n[11],v=n[12],d=n[13],x=n[14],w=n[15];m.m11=r,m.a=r,m.m21=e,m.c=e,m.m31=i,m.m41=a,m.e=a,m.m12=u,m.b=u,m.m22=o,m.d=o,m.m32=s,m.m42=f,m.f=f,m.m13=c,m.m23=h,m.m33=l,m.m43=y,m.m14=v,m.m24=d,m.m34=x,m.m44=w}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting a 6/16 values Array");var M=n[0],g=n[1],p=n[2],A=n[3],S=n[4],b=n[5];m.m11=M,m.a=M,m.m12=g,m.b=g,m.m21=p,m.c=p,m.m22=A,m.d=A,m.m14=S,m.e=S,m.m24=b,m.f=b}return m}return n.setMatrixValue=function(t){var n=this;if(!t||!t.length)return n;if(t.length&&"string"==typeof t[0]&&t[0].length){var r,e,i=String(t[0]).trim();if("none"===i)return n;if(r=i.slice(0,i.indexOf("(")),e=i.slice("matrix"===r?7:9,-1).split(",").map((function(m){return Math.abs(m)<1e-6?0:+m})),!([6,16].indexOf(e.length)>-1))throw new TypeError("CSSMatrix: expecting valid CSS matrix() / matrix3d() syntax");f(n,e)}else t[0]instanceof m?f(n,t[0].toArray()):Array.isArray(t[0])?f(n,t[0]):Array.isArray(t)&&f(n,t);return n},n.toString=function(){return(this.is2D?"matrix":"matrix3d")+"("+this.toArray(1).join(",")+")"},n.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]},n.multiply=function(m){return s(this,m)},n.translate=function(m,t,n){var e=t,i=n;return null==i&&(i=0),null==e&&(e=0),s(this,r(m,e,i))},n.scale=function(m,t,n){var r=t,e=n;return null==r&&(r=m),null==e&&(e=m),s(this,a(m,r,e))},n.rotate=function(m,t,n){var r=m,i=t,a=n;return null==i&&(i=0),null==a&&(a=r,r=0),s(this,e(r,i,a))},n.rotateAxisAngle=function(m,t,n,r){if(4!==arguments.length)throw new TypeError("CSSMatrix: expecting 4 values");return s(this,i(m,t,n,r))},n.skewX=function(m){return s(this,u(m))},n.skewY=function(m){return s(this,o(m))},n.setIdentity=function(){return f(this,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},n.transformPoint=function(m){var t=r(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}},n.transform=function(m){var t=this,n=t.m11*m.x+t.m12*m.y+t.m13*m.z+t.m14*m.w,r=t.m21*m.x+t.m22*m.y+t.m23*m.z+t.m24*m.w,e=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:n/i,y:r/i,z:e/i,w:i}},m.Translate=r,m.Rotate=e,m.RotateAxisAngle=i,m.Scale=a,m.SkewX=u,m.SkewY=o,m.Multiply=s,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 f(new m,t)},m.feedFromArray=f,m})); |
{ | ||
"name": "dommatrix", | ||
"version": "0.0.5-alpha2", | ||
"version": "0.0.6", | ||
"description": "ES6+ shim for DOMMatrix", | ||
@@ -5,0 +5,0 @@ "main": "dist/dommatrix.min.js", |
@@ -11,4 +11,35 @@ # DOMMatrix shim | ||
# Installation | ||
```js | ||
npm install dommatrix | ||
``` | ||
Download the latest version and copy the `dist/dommatrix.min.js` file to your project assets folder, then load the file in your front-end: | ||
```html | ||
<script src="./assets/js/dommatrix.min.js"> | ||
``` | ||
Alternativelly you can load from CDN: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/dommatrix/dist/dommatrix.min.js"> | ||
``` | ||
# Usage | ||
In your regular day to day usage, you will find yourself writing something like this: | ||
```js | ||
import CSSMatrix from 'dommatrix'; | ||
// init | ||
let myMatrix = new CSSMatrix('matrix(1,0.25,-0.25,1,0,0)'); | ||
// apply methods | ||
myMatrix.translate(15); | ||
myMatrix.rotate(15); | ||
// apply to styling to target | ||
element.style.transform = myMatrix.toString(); | ||
``` | ||
For the complete JavaScript API, check the [JavaScript API](https://github.com/thednp/DOMMatrix/wiki/JavaScript-API) section in our wiki. | ||
# WIKI | ||
Head over to the [wiki pages](https://github.com/thednp/DOMMatrix/wiki) for developer guidelines. | ||
For more indepth guides, head over to the [wiki pages](https://github.com/thednp/DOMMatrix/wiki) for developer guidelines. | ||
@@ -15,0 +46,0 @@ # More Info |
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
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
86430
71
2017