@thednp/dommatrix 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,361 +1 @@
1
- /**
2
- * Creates and returns a new `DOMMatrix` compatible instance
3
- * with equivalent instance methods.
4
- *
5
- * @class CSSMatrix
6
- *
7
- * @author thednp <https://github.com/thednp>
8
- * @link homepage <https://thednp.github.io/dommatrix/>
9
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix
10
- */
11
- declare class CSSMatrix {
12
- m11: number;
13
- m12: number;
14
- m13: number;
15
- m14: number;
16
- m21: number;
17
- m22: number;
18
- m23: number;
19
- m24: number;
20
- m31: number;
21
- m32: number;
22
- m33: number;
23
- m34: number;
24
- m41: number;
25
- m42: number;
26
- m43: number;
27
- m44: number;
28
- a: number;
29
- b: number;
30
- c: number;
31
- d: number;
32
- e: number;
33
- f: number;
34
- static Translate: (x: number, y: number, z: number) => CSSMatrix;
35
- static Rotate: (rx: number, ry: number, rz: number) => CSSMatrix;
36
- static RotateAxisAngle: (x?: number, y?: number, z?: number, alpha?: number) => CSSMatrix;
37
- static Scale: (x: number, y: number, z: number) => CSSMatrix;
38
- static SkewX: (angle: number) => CSSMatrix;
39
- static SkewY: (angle: number) => CSSMatrix;
40
- static Skew: (angleX: number, angleY: number) => CSSMatrix;
41
- static Multiply: (m1: CSSMatrix | DOMMatrix | JSONMatrix, m2: CSSMatrix | DOMMatrix | JSONMatrix) => CSSMatrix;
42
- static fromArray: (array: number[] | Float32Array | Float64Array) => CSSMatrix;
43
- static fromMatrix: (m: CSSMatrix | DOMMatrix | JSONMatrix) => CSSMatrix;
44
- static fromString: (source: string) => CSSMatrix;
45
- static toArray: (m: CSSMatrix | DOMMatrix | JSONMatrix, is2D?: boolean) => Matrix | Matrix3d;
46
- static isCompatibleArray: (array?: unknown) => array is Matrix | Matrix3d | Float32Array | Float64Array;
47
- static isCompatibleObject: (object?: unknown) => object is CSSMatrix | DOMMatrix | JSONMatrix;
48
- /**
49
- * @constructor
50
- * @param init accepts all parameter configurations:
51
- * * valid CSS transform string,
52
- * * CSSMatrix/DOMMatrix instance,
53
- * * a 6/16 elements *Array*.
54
- */
55
- constructor(init?: CSSMatrixInput);
56
- /**
57
- * A `Boolean` whose value is `true` if the matrix is the identity matrix. The identity
58
- * matrix is one in which every value is 0 except those on the main diagonal from top-left
59
- * to bottom-right corner (in other words, where the offsets in each direction are equal).
60
- *
61
- * @return the current property value
62
- */
63
- get isIdentity(): boolean;
64
- /**
65
- * A `Boolean` flag whose value is `true` if the matrix was initialized as a 2D matrix
66
- * and `false` if the matrix is 3D.
67
- *
68
- * @return the current property value
69
- */
70
- get is2D(): boolean;
71
- /**
72
- * The `setMatrixValue` method replaces the existing matrix with one computed
73
- * in the browser. EG: `matrix(1,0.25,-0.25,1,0,0)`
74
- *
75
- * The method accepts any *Array* values, the result of
76
- * `DOMMatrix` instance method `toFloat64Array()` / `toFloat32Array()` calls
77
- * or `CSSMatrix` instance method `toArray()`.
78
- *
79
- * This method expects valid *matrix()* / *matrix3d()* string values, as well
80
- * as other transform functions like *translateX(10px)*.
81
- *
82
- * @param source
83
- * @return the matrix instance
84
- */
85
- setMatrixValue(source?: CSSMatrixInput): CSSMatrix;
86
- /**
87
- * Returns a *Float32Array* containing elements which comprise the matrix.
88
- * The method can return either the 16 elements or the 6 elements
89
- * depending on the value of the `is2D` parameter.
90
- *
91
- * @param is2D *Array* representation of the matrix
92
- * @return an *Array* representation of the matrix
93
- */
94
- toFloat32Array(is2D?: boolean): Float32Array;
95
- /**
96
- * Returns a *Float64Array* containing elements which comprise the matrix.
97
- * The method can return either the 16 elements or the 6 elements
98
- * depending on the value of the `is2D` parameter.
99
- *
100
- * @param is2D *Array* representation of the matrix
101
- * @return an *Array* representation of the matrix
102
- */
103
- toFloat64Array(is2D?: boolean): Float64Array;
104
- /**
105
- * Creates and returns a string representation of the matrix in `CSS` matrix syntax,
106
- * using the appropriate `CSS` matrix notation.
107
- *
108
- * matrix3d *matrix3d(m11, m12, m13, m14, m21, ...)*
109
- * matrix *matrix(a, b, c, d, e, f)*
110
- *
111
- * @return a string representation of the matrix
112
- */
113
- toString(): string;
114
- /**
115
- * Returns a JSON representation of the `CSSMatrix` instance, a standard *Object*
116
- * that includes `{a,b,c,d,e,f}` and `{m11,m12,m13,..m44}` properties as well
117
- * as the `is2D` & `isIdentity` properties.
118
- *
119
- * The result can also be used as a second parameter for the `fromMatrix` static method
120
- * to load values into another matrix instance.
121
- *
122
- * @return an *Object* with all matrix values.
123
- */
124
- toJSON(): JSONMatrix;
125
- /**
126
- * The Multiply method returns a new CSSMatrix which is the result of this
127
- * matrix multiplied by the passed matrix, with the passed matrix to the right.
128
- * This matrix is not modified.
129
- *
130
- * @param m2 CSSMatrix
131
- * @return The resulted matrix.
132
- */
133
- multiply(m2: CSSMatrix | DOMMatrix | JSONMatrix): CSSMatrix;
134
- /**
135
- * The translate method returns a new matrix which is this matrix post
136
- * multiplied by a translation matrix containing the passed values. If the z
137
- * component is undefined, a 0 value is used in its place. This matrix is not
138
- * modified.
139
- *
140
- * @param x X component of the translation value.
141
- * @param y Y component of the translation value.
142
- * @param z Z component of the translation value.
143
- * @return The resulted matrix
144
- */
145
- translate(x: number, y?: number, z?: number): CSSMatrix;
146
- /**
147
- * The scale method returns a new matrix which is this matrix post multiplied by
148
- * a scale matrix containing the passed values. If the z component is undefined,
149
- * a 1 value is used in its place. If the y component is undefined, the x
150
- * component value is used in its place. This matrix is not modified.
151
- *
152
- * @param x The X component of the scale value.
153
- * @param y The Y component of the scale value.
154
- * @param z The Z component of the scale value.
155
- * @return The resulted matrix
156
- */
157
- scale(x: number, y?: number, z?: number): CSSMatrix;
158
- /**
159
- * The rotate method returns a new matrix which is this matrix post multiplied
160
- * by each of 3 rotation matrices about the major axes, first X, then Y, then Z.
161
- * If the y and z components are undefined, the x value is used to rotate the
162
- * object about the z axis, as though the vector (0,0,x) were passed. All
163
- * rotation values are in degrees. This matrix is not modified.
164
- *
165
- * @param rx The X component of the rotation, or Z if Y and Z are null.
166
- * @param ry The (optional) Y component of the rotation value.
167
- * @param rz The (optional) Z component of the rotation value.
168
- * @return The resulted matrix
169
- */
170
- rotate(rx: number, ry?: number, rz?: number): CSSMatrix;
171
- /**
172
- * The rotateAxisAngle method returns a new matrix which is this matrix post
173
- * multiplied by a rotation matrix with the given axis and `angle`. The right-hand
174
- * rule is used to determine the direction of rotation. All rotation values are
175
- * in degrees. This matrix is not modified.
176
- *
177
- * @param x The X component of the axis vector.
178
- * @param y The Y component of the axis vector.
179
- * @param z The Z component of the axis vector.
180
- * @param angle The angle of rotation about the axis vector, in degrees.
181
- * @return The resulted matrix
182
- */
183
- rotateAxisAngle(x?: number, y?: number, z?: number, angle?: number): CSSMatrix;
184
- /**
185
- * Specifies a skew transformation along the `x-axis` by the given angle.
186
- * This matrix is not modified.
187
- *
188
- * @param angle The angle amount in degrees to skew.
189
- * @return The resulted matrix
190
- */
191
- skewX(angle: number): CSSMatrix;
192
- /**
193
- * Specifies a skew transformation along the `y-axis` by the given angle.
194
- * This matrix is not modified.
195
- *
196
- * @param angle The angle amount in degrees to skew.
197
- * @return The resulted matrix
198
- */
199
- skewY(angle: number): CSSMatrix;
200
- /**
201
- * Specifies a skew transformation along both the `x-axis` and `y-axis`.
202
- * This matrix is not modified.
203
- *
204
- * @param angleX The X-angle amount in degrees to skew.
205
- * @param angleY The angle amount in degrees to skew.
206
- * @return The resulted matrix
207
- */
208
- skew(angleX: number, angleY: number): CSSMatrix;
209
- /**
210
- * Modifies the current matrix by post-multiplying it with another matrix.
211
- * This is the mutable version of multiply().
212
- *
213
- * @param m2 The matrix to multiply with
214
- * @return this matrix (modified)
215
- */
216
- multiplySelf(m2: CSSMatrix | DOMMatrix | JSONMatrix): this;
217
- /**
218
- * Modifies the current matrix by post-multiplying it with a translation matrix.
219
- * This is the mutable version of translate().
220
- *
221
- * @param x X component of the translation value.
222
- * @param y Y component of the translation value.
223
- * @param z Z component of the translation value.
224
- * @return this matrix (modified)
225
- */
226
- translateSelf(x: number, y?: number, z?: number): this;
227
- /**
228
- * Modifies the current matrix by post-multiplying it with a scale matrix.
229
- * This is the mutable version of scale().
230
- *
231
- * @param x The X component of the scale value.
232
- * @param y The Y component of the scale value.
233
- * @param z The Z component of the scale value.
234
- * @return this matrix (modified)
235
- */
236
- scaleSelf(x: number, y?: number, z?: number): this;
237
- /**
238
- * Modifies the current matrix by post-multiplying it with a rotation matrix.
239
- * This is the mutable version of rotate().
240
- *
241
- * @param rx The X component of the rotation, or Z if Y and Z are null.
242
- * @param ry The (optional) Y component of the rotation value.
243
- * @param rz The (optional) Z component of the rotation value.
244
- * @return this matrix (modified)
245
- */
246
- rotateSelf(rx: number, ry?: number, rz?: number): this;
247
- /**
248
- * Modifies the current matrix by post-multiplying it with a rotation matrix
249
- * with the given axis and angle.
250
- * This is the mutable version of rotateAxisAngle().
251
- *
252
- * @param x The X component of the axis vector.
253
- * @param y The Y component of the axis vector.
254
- * @param z The Z component of the axis vector.
255
- * @param angle The angle of rotation about the axis vector, in degrees.
256
- * @return this matrix (modified)
257
- */
258
- rotateAxisAngleSelf(x?: number, y?: number, z?: number, angle?: number): this;
259
- /**
260
- * Modifies the current matrix by post-multiplying it with a skewX matrix.
261
- * This is the mutable version of skewX().
262
- *
263
- * @param angle The angle amount in degrees to skew.
264
- * @return this matrix (modified)
265
- */
266
- skewXSelf(angle: number): this;
267
- /**
268
- * Modifies the current matrix by post-multiplying it with a skewY matrix.
269
- * This is the mutable version of skewY().
270
- *
271
- * @param angle The angle amount in degrees to skew.
272
- * @return this matrix (modified)
273
- */
274
- skewYSelf(angle: number): this;
275
- /**
276
- * Modifies the current matrix by post-multiplying it with a skew matrix.
277
- * This is the mutable version of skew().
278
- *
279
- * @param angleX The X-angle amount in degrees to skew.
280
- * @param angleY The Y-angle amount in degrees to skew.
281
- * @return this matrix (modified)
282
- */
283
- skewSelf(angleX: number, angleY: number): this;
284
- /**
285
- * Transforms a specified vector using the matrix, returning a new
286
- * {x,y,z,w} Tuple *Object* comprising the transformed vector.
287
- * Neither the matrix nor the original vector are altered.
288
- *
289
- * The method is equivalent with `transformPoint()` method
290
- * of the `DOMMatrix` constructor.
291
- *
292
- * @param t Tuple with `{x,y,z,w}` components
293
- * @return the resulting Tuple
294
- */
295
- transformPoint(t: PointTuple | DOMPoint): PointTuple | DOMPoint;
296
- }
297
- export default CSSMatrix;
298
-
299
- /** All CSSMatrix compatible initialization values. */
300
- declare type CSSMatrixInput = string | number[] | Matrix | Matrix3d | CSSMatrix | DOMMatrix | JSONMatrix | Float32Array | Float64Array;
301
-
302
- /** The result of **CSSMatrix.toJSON()** / **DOMMatrix.toJSON()** instance calls. */
303
- declare interface JSONMatrix {
304
- m11: number;
305
- m12: number;
306
- m13: number;
307
- m14: number;
308
- m21: number;
309
- m22: number;
310
- m23: number;
311
- m24: number;
312
- m31: number;
313
- m32: number;
314
- m33: number;
315
- m34: number;
316
- m41: number;
317
- m42: number;
318
- m43: number;
319
- m44: number;
320
- a: number;
321
- b: number;
322
- c: number;
323
- d: number;
324
- e: number;
325
- f: number;
326
- is2D: boolean;
327
- isIdentity: boolean;
328
- }
329
-
330
- /** An array of 6 numbers representing a 2D matrix. */
331
- declare type Matrix = [number, number, number, number, number, number];
332
-
333
- /** An array of 16 numbers representing a 3D matrix. */
334
- declare type Matrix3d = [
335
- number,
336
- number,
337
- number,
338
- number,
339
- number,
340
- number,
341
- number,
342
- number,
343
- number,
344
- number,
345
- number,
346
- number,
347
- number,
348
- number,
349
- number,
350
- number
351
- ];
352
-
353
- /** A DOMMPoint compatible Tuple. */
354
- declare interface PointTuple {
355
- x: number;
356
- y: number;
357
- z: number;
358
- w: number;
359
- }
360
-
361
1
  export { }
package/dist/dommatrix.js CHANGED
@@ -1,2 +1,2 @@
1
- var CSSMatrix=(function(){"use strict";const I={a:1,b:0,c:0,d:1,e:0,f:0,m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:0,m42:0,m43:0,m44:1,is2D:!0,isIdentity:!0},R=s=>(s instanceof Float64Array||s instanceof Float32Array||Array.isArray(s)&&s.every(t=>typeof t=="number"))&&[6,16].some(t=>s.length===t),T=s=>s instanceof DOMMatrix||s instanceof M||typeof s=="object"&&Object.keys(I).every(t=>s&&t in s),A=s=>{const t=new M,e=Array.from(s);if(!R(e))throw TypeError(`CSSMatrix: "${e.join(",")}" must be an array with 6/16 numbers.`);if(e.length===16){const[i,n,m,a,h,r,l,c,u,f,S,o,y,p,d,w]=e;t.m11=i,t.a=i,t.m21=h,t.c=h,t.m31=u,t.m41=y,t.e=y,t.m12=n,t.b=n,t.m22=r,t.d=r,t.m32=f,t.m42=p,t.f=p,t.m13=m,t.m23=l,t.m33=S,t.m43=d,t.m14=a,t.m24=c,t.m34=o,t.m44=w}else if(e.length===6){const[i,n,m,a,h,r]=e;t.m11=i,t.a=i,t.m12=n,t.b=n,t.m21=m,t.c=m,t.m22=a,t.d=a,t.m41=h,t.e=h,t.m42=r,t.f=r}return t},N=s=>{if(T(s))return A([s.m11,s.m12,s.m13,s.m14,s.m21,s.m22,s.m23,s.m24,s.m31,s.m32,s.m33,s.m34,s.m41,s.m42,s.m43,s.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)},E=s=>{if(typeof s!="string")throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a string.`);const t=String(s).replace(/\s/g,""),e=new M,i=`CSSMatrix: invalid transform string "${s}"`;return t.split(")").filter(n=>n).forEach(n=>{const[m,a]=n.split("(");if(!a)throw TypeError(i);const h=a.split(",").map(o=>o.includes("rad")?parseFloat(o)*(180/Math.PI):parseFloat(o)),[r,l,c,u]=h,f=[r,l,c],S=[r,l,c,u];if(m==="perspective"&&r&&[l,c].every(o=>o===void 0))e.m34=-1/r;else if(m.includes("matrix")&&[6,16].includes(h.length)&&h.every(o=>!Number.isNaN(+o))){const o=h.map(y=>Math.abs(y)<1e-6?0:y);e.multiplySelf(A(o))}else if(m==="translate3d"&&f.every(o=>!Number.isNaN(+o)))e.translateSelf(r,l,c);else if(m==="translate"&&r&&c===void 0)e.translateSelf(r,l||0,0);else if(m==="rotate3d"&&S.every(o=>!Number.isNaN(+o))&&u)e.rotateAxisAngleSelf(r,l,c,u);else if(m==="rotate"&&r&&[l,c].every(o=>o===void 0))e.rotateSelf(0,0,r);else if(m==="scale3d"&&f.every(o=>!Number.isNaN(+o))&&f.some(o=>o!==1))e.scaleSelf(r,l,c);else if(m==="scale"&&!Number.isNaN(r)&&(r!==1||l!==1)&&c===void 0){const y=Number.isNaN(+l)?r:l;e.scaleSelf(r,y,1)}else if(m==="skew"&&(r||!Number.isNaN(r)&&l)&&c===void 0)e.skewSelf(r,l||0);else if(["translate","rotate","scale","skew"].some(o=>m.includes(o))&&/[XYZ]/.test(m)&&r&&[l,c].every(o=>o===void 0))if(m==="skewX"||m==="skewY")e[m==="skewX"?"skewXSelf":"skewYSelf"](r);else{const o=m.replace(/[XYZ]/,""),y=m.replace(o,""),p=["X","Y","Z"].indexOf(y),d=o==="scale"?1:0,w=o+"Self",g=[p===0?r:d,p===1?r:d,p===2?r:d];e[w](...g)}else throw TypeError(i)}),e},x=(s,t)=>t?[s.a,s.b,s.c,s.d,s.e,s.f]:[s.m11,s.m12,s.m13,s.m14,s.m21,s.m22,s.m23,s.m24,s.m31,s.m32,s.m33,s.m34,s.m41,s.m42,s.m43,s.m44],v=(s,t,e)=>{const i=new M;return i.m41=s,i.e=s,i.m42=t,i.f=t,i.m43=e,i},k=(s,t,e)=>{const i=new M,n=Math.PI/180,m=s*n,a=t*n,h=e*n,r=Math.cos(m),l=-Math.sin(m),c=Math.cos(a),u=-Math.sin(a),f=Math.cos(h),S=-Math.sin(h),o=c*f,y=-c*S;i.m11=o,i.a=o,i.m12=y,i.b=y,i.m13=u;const p=l*u*f+r*S;i.m21=p,i.c=p;const d=r*f-l*u*S;return i.m22=d,i.d=d,i.m23=-l*c,i.m31=l*S-r*u*f,i.m32=l*f+r*u*S,i.m33=r*c,i},X=(s=0,t=0,e=0,i=0)=>{const n=new M,m=Math.sqrt(s*s+t*t+e*e);if(m===0)return n;const a=s/m,h=t/m,r=e/m,l=i*(Math.PI/360),c=Math.sin(l),u=Math.cos(l),f=c*c,S=a*a,o=h*h,y=r*r,p=1-2*(o+y)*f;n.m11=p,n.a=p;const d=2*(a*h*f+r*c*u);n.m12=d,n.b=d,n.m13=2*(a*r*f-h*c*u);const w=2*(h*a*f-r*c*u);n.m21=w,n.c=w;const g=1-2*(y+S)*f;return n.m22=g,n.d=g,n.m23=2*(h*r*f+a*c*u),n.m31=2*(r*a*f+h*c*u),n.m32=2*(r*h*f-a*c*u),n.m33=1-2*(S+o)*f,n},O=(s,t,e)=>{const i=new M;return i.m11=s,i.a=s,i.m22=t,i.d=t,i.m33=e,i},b=(s,t)=>{const e=new M;if(s){const i=s*Math.PI/180,n=Math.tan(i);e.m21=n,e.c=n}if(t){const i=t*Math.PI/180,n=Math.tan(i);e.m12=n,e.b=n}return e},Y=s=>b(s,0),C=s=>b(0,s),F=(s,t)=>{const e=t.m11*s.m11+t.m12*s.m21+t.m13*s.m31+t.m14*s.m41,i=t.m11*s.m12+t.m12*s.m22+t.m13*s.m32+t.m14*s.m42,n=t.m11*s.m13+t.m12*s.m23+t.m13*s.m33+t.m14*s.m43,m=t.m11*s.m14+t.m12*s.m24+t.m13*s.m34+t.m14*s.m44,a=t.m21*s.m11+t.m22*s.m21+t.m23*s.m31+t.m24*s.m41,h=t.m21*s.m12+t.m22*s.m22+t.m23*s.m32+t.m24*s.m42,r=t.m21*s.m13+t.m22*s.m23+t.m23*s.m33+t.m24*s.m43,l=t.m21*s.m14+t.m22*s.m24+t.m23*s.m34+t.m24*s.m44,c=t.m31*s.m11+t.m32*s.m21+t.m33*s.m31+t.m34*s.m41,u=t.m31*s.m12+t.m32*s.m22+t.m33*s.m32+t.m34*s.m42,f=t.m31*s.m13+t.m32*s.m23+t.m33*s.m33+t.m34*s.m43,S=t.m31*s.m14+t.m32*s.m24+t.m33*s.m34+t.m34*s.m44,o=t.m41*s.m11+t.m42*s.m21+t.m43*s.m31+t.m44*s.m41,y=t.m41*s.m12+t.m42*s.m22+t.m43*s.m32+t.m44*s.m42,p=t.m41*s.m13+t.m42*s.m23+t.m43*s.m33+t.m44*s.m43,d=t.m41*s.m14+t.m42*s.m24+t.m43*s.m34+t.m44*s.m44;return A([e,i,n,m,a,h,r,l,c,u,f,S,o,y,p,d])};class M{static Translate=v;static Rotate=k;static RotateAxisAngle=X;static Scale=O;static SkewX=Y;static SkewY=C;static Skew=b;static Multiply=F;static fromArray=A;static fromMatrix=N;static fromString=E;static toArray=x;static isCompatibleArray=R;static isCompatibleObject=T;constructor(t){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,t?this.setMatrixValue(t):this}get isIdentity(){return this.m11===1&&this.m12===0&&this.m13===0&&this.m14===0&&this.m21===0&&this.m22===1&&this.m23===0&&this.m24===0&&this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m41===0&&this.m42===0&&this.m43===0&&this.m44===1}get is2D(){return this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m43===0&&this.m44===1}setMatrixValue(t){return typeof t=="string"&&t.length&&t!=="none"?E(t):Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array?A(t):typeof t=="object"?N(t):this}toFloat32Array(t){return Float32Array.from(x(this,t))}toFloat64Array(t){return Float64Array.from(x(this,t))}toString(){const{is2D:t}=this,e=this.toFloat64Array(t).join(", ");return`${t?"matrix":"matrix3d"}(${e})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return F(this,t)}translate(t,e,i){return this.multiply(v(t,e??0,i??0))}scale(t,e,i){return this.multiply(O(t,e??t,i??1))}rotate(t,e,i){let n=t,m=e||0,a=i||0;return typeof t=="number"&&typeof e>"u"&&typeof i>"u"&&(a=n,n=0,m=0),this.multiply(k(n,m,a))}rotateAxisAngle(t=0,e=0,i=0,n=0){if([t,e,i,n].some(a=>!Number.isFinite(a)))throw new TypeError("CSSMatrix: expecting 4 values");return Math.sqrt(t*t+e*e+i*i)===0?N(this):this.multiply(X(t,e,i,n))}skewX(t){return this.multiply(Y(t))}skewY(t){return this.multiply(C(t))}skew(t,e){return this.multiply(b(t,e))}multiplySelf(t){const e=F(this,t);return Object.assign(this,e),this}translateSelf(t,e,i){return this.multiplySelf(v(t,e??0,i??0))}scaleSelf(t,e,i){return this.multiplySelf(O(t,e??t,i??1))}rotateSelf(t,e,i){let n=t,m=e||0,a=i||0;return typeof t=="number"&&typeof e>"u"&&typeof i>"u"&&(a=n,n=0,m=0),this.multiplySelf(k(n,m,a))}rotateAxisAngleSelf(t=0,e=0,i=0,n=0){if([t,e,i,n].some(a=>!Number.isFinite(a)))throw new TypeError("CSSMatrix: expecting 4 values");return Math.sqrt(t*t+e*e+i*i)===0?this:this.multiplySelf(X(t,e,i,n))}skewXSelf(t){return this.multiplySelf(Y(t))}skewYSelf(t){return this.multiplySelf(C(t))}skewSelf(t,e){return this.multiplySelf(b(t,e))}transformPoint(t){const e=this.m11*t.x+this.m21*t.y+this.m31*t.z+this.m41*t.w,i=this.m12*t.x+this.m22*t.y+this.m32*t.z+this.m42*t.w,n=this.m13*t.x+this.m23*t.y+this.m33*t.z+this.m43*t.w,m=this.m14*t.x+this.m24*t.y+this.m34*t.z+this.m44*t.w;return t instanceof DOMPoint?new DOMPoint(e,i,n,m):{x:e,y:i,z:n,w:m}}}return M})();
2
- //# sourceMappingURL=dommatrix.js.map
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.CSSMatrix=t())})(this,function(){var e={a:1,b:0,c:0,d:1,e:0,f:0,m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:0,m42:0,m43:0,m44:1,is2D:!0,isIdentity:!0},t=e=>(e instanceof Float64Array||e instanceof Float32Array||Array.isArray(e)&&e.every(e=>typeof e==`number`))&&[6,16].some(t=>e.length===t),n=t=>t instanceof DOMMatrix||t instanceof h||typeof t==`object`&&Object.keys(e).every(e=>t&&e in t),r=e=>{let n=new h,r=Array.from(e);if(!t(r))throw TypeError(`CSSMatrix: "${r.join(`,`)}" must be an array with 6/16 numbers.`);if(r.length===16){let[e,t,i,a,o,s,c,l,u,d,f,p,m,h,g,_]=r;n.m11=e,n.a=e,n.m21=o,n.c=o,n.m31=u,n.m41=m,n.e=m,n.m12=t,n.b=t,n.m22=s,n.d=s,n.m32=d,n.m42=h,n.f=h,n.m13=i,n.m23=c,n.m33=f,n.m43=g,n.m14=a,n.m24=l,n.m34=p,n.m44=_}else if(r.length===6){let[e,t,i,a,o,s]=r;n.m11=e,n.a=e,n.m12=t,n.b=t,n.m21=i,n.c=i,n.m22=a,n.d=a,n.m41=o,n.e=o,n.m42=s,n.f=s}return n},i=e=>{if(n(e))return r([e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)},a=e=>{if(typeof e!=`string`)throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);let t=String(e).replace(/\s/g,``),n=new h,i=`CSSMatrix: invalid transform string "${e}"`;return t.split(`)`).filter(e=>e).forEach(e=>{let[t,a]=e.split(`(`);if(!a)throw TypeError(i);let o=a.split(`,`).map(e=>e.includes(`rad`)?180/Math.PI*parseFloat(e):parseFloat(e)),[s,c,l,u]=o,d=[s,c,l],f=[s,c,l,u];if(t===`perspective`&&s&&[c,l].every(e=>e===void 0))n.m34=-1/s;else if(t.includes(`matrix`)&&[6,16].includes(o.length)&&o.every(e=>!Number.isNaN(+e))){let e=o.map(e=>Math.abs(e)<1e-6?0:e);n.multiplySelf(r(e))}else if(t===`translate3d`&&d.every(e=>!Number.isNaN(+e)))n.translateSelf(s,c,l);else if(t===`translate`&&s&&l===void 0)n.translateSelf(s,c||0,0);else if(t===`rotate3d`&&f.every(e=>!Number.isNaN(+e))&&u)n.rotateAxisAngleSelf(s,c,l,u);else if(t===`rotate`&&s&&[c,l].every(e=>e===void 0))n.rotateSelf(0,0,s);else if(t===`scale3d`&&d.every(e=>!Number.isNaN(+e))&&d.some(e=>e!==1))n.scaleSelf(s,c,l);else if(t===`scale`&&!Number.isNaN(s)&&(s!==1||c!==1)&&l===void 0){let e=Number.isNaN(+c)?s:c;n.scaleSelf(s,e,1)}else if(t===`skew`&&(s||!Number.isNaN(s)&&c)&&l===void 0)n.skewSelf(s,c||0);else if([`translate`,`rotate`,`scale`,`skew`].some(e=>t.includes(e))&&/[XYZ]/.test(t)&&s&&[c,l].every(e=>e===void 0))if(t===`skewX`||t===`skewY`)n[t===`skewX`?`skewXSelf`:`skewYSelf`](s);else{let e=t.replace(/[XYZ]/,``),r=t.replace(e,``),i=[`X`,`Y`,`Z`].indexOf(r),a=e===`scale`?1:0,o=e+`Self`,c=[i===0?s:a,i===1?s:a,i===2?s:a];n[o](...c)}else throw TypeError(i)}),n},o=(e,t)=>t?[e.a,e.b,e.c,e.d,e.e,e.f]:[e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44],s=(e,t,n)=>{let r=new h;return r.m41=e,r.e=e,r.m42=t,r.f=t,r.m43=n,r},c=(e,t,n)=>{let r=new h,i=Math.PI/180,a=e*i,o=t*i,s=n*i,c=Math.cos(a),l=-Math.sin(a),u=Math.cos(o),d=-Math.sin(o),f=Math.cos(s),p=-Math.sin(s),m=u*f,g=-u*p;r.m11=m,r.a=m,r.m12=g,r.b=g,r.m13=d;let _=l*d*f+c*p;r.m21=_,r.c=_;let v=c*f-l*d*p;return r.m22=v,r.d=v,r.m23=-l*u,r.m31=l*p-c*d*f,r.m32=l*f+c*d*p,r.m33=c*u,r},l=(e=0,t=0,n=0,r=0)=>{let i=new h,a=Math.sqrt(e*e+t*t+n*n);if(a===0)return i;let o=e/a,s=t/a,c=n/a,l=Math.PI/360*r,u=Math.sin(l),d=Math.cos(l),f=u*u,p=o*o,m=s*s,g=c*c,_=1-2*(m+g)*f;i.m11=_,i.a=_;let v=2*(o*s*f+c*u*d);i.m12=v,i.b=v,i.m13=2*(o*c*f-s*u*d);let y=2*(s*o*f-c*u*d);i.m21=y,i.c=y;let b=1-2*(g+p)*f;return i.m22=b,i.d=b,i.m23=2*(s*c*f+o*u*d),i.m31=2*(c*o*f+s*u*d),i.m32=2*(c*s*f-o*u*d),i.m33=1-2*(p+m)*f,i},u=(e,t,n)=>{let r=new h;return r.m11=e,r.a=e,r.m22=t,r.d=t,r.m33=n,r},d=(e,t)=>{let n=new h;if(e){let t=e*Math.PI/180,r=Math.tan(t);n.m21=r,n.c=r}if(t){let e=t*Math.PI/180,r=Math.tan(e);n.m12=r,n.b=r}return n},f=e=>d(e,0),p=e=>d(0,e),m=(e,t)=>r([t.m11*e.m11+t.m12*e.m21+t.m13*e.m31+t.m14*e.m41,t.m11*e.m12+t.m12*e.m22+t.m13*e.m32+t.m14*e.m42,t.m11*e.m13+t.m12*e.m23+t.m13*e.m33+t.m14*e.m43,t.m11*e.m14+t.m12*e.m24+t.m13*e.m34+t.m14*e.m44,t.m21*e.m11+t.m22*e.m21+t.m23*e.m31+t.m24*e.m41,t.m21*e.m12+t.m22*e.m22+t.m23*e.m32+t.m24*e.m42,t.m21*e.m13+t.m22*e.m23+t.m23*e.m33+t.m24*e.m43,t.m21*e.m14+t.m22*e.m24+t.m23*e.m34+t.m24*e.m44,t.m31*e.m11+t.m32*e.m21+t.m33*e.m31+t.m34*e.m41,t.m31*e.m12+t.m32*e.m22+t.m33*e.m32+t.m34*e.m42,t.m31*e.m13+t.m32*e.m23+t.m33*e.m33+t.m34*e.m43,t.m31*e.m14+t.m32*e.m24+t.m33*e.m34+t.m34*e.m44,t.m41*e.m11+t.m42*e.m21+t.m43*e.m31+t.m44*e.m41,t.m41*e.m12+t.m42*e.m22+t.m43*e.m32+t.m44*e.m42,t.m41*e.m13+t.m42*e.m23+t.m43*e.m33+t.m44*e.m43,t.m41*e.m14+t.m42*e.m24+t.m43*e.m34+t.m44*e.m44]),h=class{static Translate=s;static Rotate=c;static RotateAxisAngle=l;static Scale=u;static SkewX=f;static SkewY=p;static Skew=d;static Multiply=m;static fromArray=r;static fromMatrix=i;static fromString=a;static toArray=o;static isCompatibleArray=t;static isCompatibleObject=n;constructor(e){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,e?this.setMatrixValue(e):this}get isIdentity(){return this.m11===1&&this.m12===0&&this.m13===0&&this.m14===0&&this.m21===0&&this.m22===1&&this.m23===0&&this.m24===0&&this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m41===0&&this.m42===0&&this.m43===0&&this.m44===1}get is2D(){return this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m43===0&&this.m44===1}setMatrixValue(e){return typeof e==`string`&&e.length&&e!==`none`?a(e):Array.isArray(e)||e instanceof Float64Array||e instanceof Float32Array?r(e):typeof e==`object`?i(e):this}toFloat32Array(e){return Float32Array.from(o(this,e))}toFloat64Array(e){return Float64Array.from(o(this,e))}toString(){let{is2D:e}=this,t=this.toFloat64Array(e).join(`, `);return`${e?`matrix`:`matrix3d`}(${t})`}toJSON(){let{is2D:e,isIdentity:t}=this;return{...this,is2D:e,isIdentity:t}}multiply(e){return m(this,e)}translate(e,t,n){return this.multiply(s(e,t??0,n??0))}scale(e,t,n){return this.multiply(u(e,t??e,n??1))}rotate(e,t,n){let r=e,i=t||0,a=n||0;return typeof e==`number`&&t===void 0&&n===void 0&&(a=r,r=0,i=0),this.multiply(c(r,i,a))}rotateAxisAngle(e=0,t=0,n=0,r=0){if([e,t,n,r].some(e=>!Number.isFinite(e)))throw TypeError(`CSSMatrix: expecting 4 values`);return Math.sqrt(e*e+t*t+n*n)===0?i(this):this.multiply(l(e,t,n,r))}skewX(e){return this.multiply(f(e))}skewY(e){return this.multiply(p(e))}skew(e,t){return this.multiply(d(e,t))}multiplySelf(e){let t=m(this,e);return Object.assign(this,t),this}translateSelf(e,t,n){return this.multiplySelf(s(e,t??0,n??0))}scaleSelf(e,t,n){return this.multiplySelf(u(e,t??e,n??1))}rotateSelf(e,t,n){let r=e,i=t||0,a=n||0;return typeof e==`number`&&t===void 0&&n===void 0&&(a=r,r=0,i=0),this.multiplySelf(c(r,i,a))}rotateAxisAngleSelf(e=0,t=0,n=0,r=0){if([e,t,n,r].some(e=>!Number.isFinite(e)))throw TypeError(`CSSMatrix: expecting 4 values`);return Math.sqrt(e*e+t*t+n*n)===0?this:this.multiplySelf(l(e,t,n,r))}skewXSelf(e){return this.multiplySelf(f(e))}skewYSelf(e){return this.multiplySelf(p(e))}skewSelf(e,t){return this.multiplySelf(d(e,t))}transformPoint(e){let t=this.m11*e.x+this.m21*e.y+this.m31*e.z+this.m41*e.w,n=this.m12*e.x+this.m22*e.y+this.m32*e.z+this.m42*e.w,r=this.m13*e.x+this.m23*e.y+this.m33*e.z+this.m43*e.w,i=this.m14*e.x+this.m24*e.y+this.m34*e.z+this.m44*e.w;return e instanceof DOMPoint?new DOMPoint(t,n,r,i):{x:t,y:n,z:r,w:i}}};return h});
2
+ //# sourceMappingURL=dommatrix.js.map