@thednp/dommatrix 3.0.4 → 3.0.6

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,5 +1,6 @@
1
1
  //#region src/index.ts
2
- var e = {
2
+ /** A model for JSONMatrix */
3
+ const JSON_MATRIX = {
3
4
  a: 1,
4
5
  b: 0,
5
6
  c: 0,
@@ -22,284 +23,846 @@ var e = {
22
23
  m42: 0,
23
24
  m43: 0,
24
25
  m44: 1,
25
- is2D: !0,
26
- isIdentity: !0
27
- }, 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) => {
28
- let n = new h(), r = Array.from(e);
29
- if (!t(r)) throw TypeError(`CSSMatrix: "${r.join(",")}" must be an array with 6/16 numbers.`);
26
+ is2D: true,
27
+ isIdentity: true
28
+ };
29
+ /** Checks if an array is compatible with CSSMatrix */
30
+ const isCompatibleArray = (array) => {
31
+ return (array instanceof Float64Array || array instanceof Float32Array || Array.isArray(array) && array.every((x) => typeof x === "number")) && [6, 16].some((x) => array.length === x);
32
+ };
33
+ /** Checks if an object is compatible with CSSMatrix */
34
+ const isCompatibleObject = (object) => {
35
+ return typeof DOMMatrix !== "undefined" && object instanceof DOMMatrix || object instanceof CSSMatrix || typeof object === "object" && Object.keys(JSON_MATRIX).every((k) => object && k in object);
36
+ };
37
+ /**
38
+ * Creates a new mutable `CSSMatrix` instance given an array of 16/6 floating point values.
39
+ * This static method invalidates arrays that contain non-number elements.
40
+ *
41
+ * If the array has six values, the result is a 2D matrix; if the array has 16 values,
42
+ * the result is a 3D matrix. Otherwise, a TypeError exception is thrown.
43
+ *
44
+ * @param array an `Array` to feed values from.
45
+ * @return the resulted matrix.
46
+ */
47
+ const fromArray = (array) => {
48
+ const m = new CSSMatrix();
49
+ const a = Array.from(array);
50
+ if (!isCompatibleArray(a)) throw TypeError(`CSSMatrix: "${a.join(",")}" must be an array with 6/16 numbers.`);
30
51
  // istanbul ignore else @preserve
31
- if (r.length === 16) {
32
- let [e, t, i, a, o, s, c, l, u, d, f, p, m, h, g, _] = r;
33
- 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 = _;
34
- } else if (r.length === 6) {
35
- let [e, t, i, a, o, s] = r;
36
- 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;
52
+ if (a.length === 16) {
53
+ const [m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44] = a;
54
+ m.m11 = m11;
55
+ m.a = m11;
56
+ m.m21 = m21;
57
+ m.c = m21;
58
+ m.m31 = m31;
59
+ m.m41 = m41;
60
+ m.e = m41;
61
+ m.m12 = m12;
62
+ m.b = m12;
63
+ m.m22 = m22;
64
+ m.d = m22;
65
+ m.m32 = m32;
66
+ m.m42 = m42;
67
+ m.f = m42;
68
+ m.m13 = m13;
69
+ m.m23 = m23;
70
+ m.m33 = m33;
71
+ m.m43 = m43;
72
+ m.m14 = m14;
73
+ m.m24 = m24;
74
+ m.m34 = m34;
75
+ m.m44 = m44;
76
+ } else if (a.length === 6) {
77
+ const [M11, M12, M21, M22, M41, M42] = a;
78
+ m.m11 = M11;
79
+ m.a = M11;
80
+ m.m12 = M12;
81
+ m.b = M12;
82
+ m.m21 = M21;
83
+ m.c = M21;
84
+ m.m22 = M22;
85
+ m.d = M22;
86
+ m.m41 = M41;
87
+ m.e = M41;
88
+ m.m42 = M42;
89
+ m.f = M42;
37
90
  }
38
- return n;
39
- }, i = (e) => {
40
- if (n(e)) return r([
41
- e.m11,
42
- e.m12,
43
- e.m13,
44
- e.m14,
45
- e.m21,
46
- e.m22,
47
- e.m23,
48
- e.m24,
49
- e.m31,
50
- e.m32,
51
- e.m33,
52
- e.m34,
53
- e.m41,
54
- e.m42,
55
- e.m43,
56
- e.m44
91
+ return m;
92
+ };
93
+ /**
94
+ * Creates a new mutable `CSSMatrix` instance given an existing matrix or a
95
+ * `DOMMatrix` instance which provides the values for its properties.
96
+ *
97
+ * @param m the source matrix to feed values from.
98
+ * @return the resulted matrix.
99
+ */
100
+ const fromMatrix = (m) => {
101
+ if (isCompatibleObject(m)) return fromArray([
102
+ m.m11,
103
+ m.m12,
104
+ m.m13,
105
+ m.m14,
106
+ m.m21,
107
+ m.m22,
108
+ m.m23,
109
+ m.m24,
110
+ m.m31,
111
+ m.m32,
112
+ m.m33,
113
+ m.m34,
114
+ m.m41,
115
+ m.m42,
116
+ m.m43,
117
+ m.m44
57
118
  ]);
58
- throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);
59
- }, a = (e) => {
60
- if (typeof e != "string") throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);
61
- let t = String(e).replace(/\s/g, ""), n = new h(), i = `CSSMatrix: invalid transform string "${e}"`;
62
- return t.split(")").filter((e) => e).forEach((e) => {
63
- let [t, a] = e.split("(");
64
- if (!a) throw TypeError(i);
65
- let o = a.split(",").map((e) => e.includes("rad") ? 180 / Math.PI * parseFloat(e) : parseFloat(e)), [s, c, l, u] = o, d = [
66
- s,
67
- c,
68
- l
69
- ], f = [
70
- s,
71
- c,
72
- l,
73
- u
119
+ throw TypeError(`CSSMatrix: "${JSON.stringify(m)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);
120
+ };
121
+ /**
122
+ * Creates a new mutable `CSSMatrix` given any valid CSS transform string,
123
+ * or what we call `TransformList`:
124
+ *
125
+ * * `matrix(a, b, c, d, e, f)` - valid matrix() transform function
126
+ * * `matrix3d(m11, m12, m13, ...m44)` - valid matrix3d() transform function
127
+ * * `translate(tx, ty) rotateX(alpha)` - any valid transform function(s)
128
+ *
129
+ * @copyright thednp © 2021
130
+ *
131
+ * @param source valid CSS transform string syntax.
132
+ * @return the resulted matrix.
133
+ */
134
+ const fromString = (source) => {
135
+ if (typeof source !== "string") throw TypeError(`CSSMatrix: "${JSON.stringify(source)}" is not a string.`);
136
+ const str = String(source).replace(/\s/g, "");
137
+ const m = new CSSMatrix();
138
+ const invalidStringError = `CSSMatrix: invalid transform string "${source}"`;
139
+ str.split(")").filter((f) => f).forEach((tf) => {
140
+ const [prop, value] = tf.split("(");
141
+ if (!value) throw TypeError(invalidStringError);
142
+ const components = value.split(",").map((n) => n.includes("rad") ? parseFloat(n) * (180 / Math.PI) : parseFloat(n));
143
+ const [x, y, z, a] = components;
144
+ const xyz = [
145
+ x,
146
+ y,
147
+ z
74
148
  ];
75
- if (t === "perspective" && s && [c, l].every((e) => e === void 0)) n.m34 = -1 / s;
76
- else if (t.includes("matrix") && [6, 16].includes(o.length) && o.every((e) => !Number.isNaN(+e))) {
77
- let e = o.map((e) => Math.abs(e) < 1e-6 ? 0 : e);
78
- n.multiplySelf(r(e));
79
- } else if (t === "translate3d" && d.every((e) => !Number.isNaN(+e))) n.translateSelf(s, c, l);
80
- else if (t === "translate" && s && l === void 0) n.translateSelf(s, c || 0, 0);
81
- else if (t === "rotate3d" && f.every((e) => !Number.isNaN(+e)) && u) n.rotateAxisAngleSelf(s, c, l, u);
82
- else if (t === "rotate" && s && [c, l].every((e) => e === void 0)) n.rotateSelf(0, 0, s);
83
- else if (t === "scale3d" && d.every((e) => !Number.isNaN(+e)) && d.some((e) => e !== 1)) n.scaleSelf(s, c, l);
84
- else if (t === "scale" && !Number.isNaN(s) && (s !== 1 || c !== 1) && l === void 0) {
85
- let e = Number.isNaN(+c) ? s : c;
86
- n.scaleSelf(s, e, 1);
87
- } else if (t === "skew" && (s || !Number.isNaN(s) && c) && l === void 0) n.skewSelf(s, c || 0);
149
+ const xyza = [
150
+ x,
151
+ y,
152
+ z,
153
+ a
154
+ ];
155
+ if (prop === "perspective" && x && [y, z].every((n) => n === void 0)) m.m34 = -1 / x;
156
+ else if (prop.includes("matrix") && [6, 16].includes(components.length) && components.every((n) => !Number.isNaN(+n))) {
157
+ const values = components.map((n) => Math.abs(n) < 1e-6 ? 0 : n);
158
+ m.multiplySelf(fromArray(values));
159
+ } else if (prop === "translate3d" && xyz.every((n) => !Number.isNaN(+n))) m.translateSelf(x, y, z);
160
+ else if (prop === "translate" && x && z === void 0) m.translateSelf(x, y || 0, 0);
161
+ else if (prop === "rotate3d" && xyza.every((n) => !Number.isNaN(+n)) && a) m.rotateAxisAngleSelf(x, y, z, a);
162
+ else if (prop === "rotate" && x && [y, z].every((n) => n === void 0)) m.rotateSelf(0, 0, x);
163
+ else if (prop === "scale3d" && xyz.every((n) => !Number.isNaN(+n)) && xyz.some((n) => n !== 1)) m.scaleSelf(x, y, z);
164
+ else if (prop === "scale" && !Number.isNaN(x) && (x !== 1 || y !== 1) && z === void 0) {
165
+ const sy = Number.isNaN(+y) ? x : y;
166
+ m.scaleSelf(x, sy, 1);
167
+ } else if (prop === "skew" && (x || !Number.isNaN(x) && y) && z === void 0) m.skewSelf(x, y || 0);
88
168
  else if ([
89
169
  "translate",
90
170
  "rotate",
91
171
  "scale",
92
172
  "skew"
93
- ].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);
173
+ ].some((p) => prop.includes(p)) && /[XYZ]/.test(prop) && x && [y, z].every((n) => n === void 0)) if ("skewX" === prop || "skewY" === prop) m["skewX" === prop ? "skewXSelf" : "skewYSelf"](x);
94
174
  else {
95
- let e = t.replace(/[XYZ]/, ""), r = t.replace(e, ""), i = [
175
+ const fn = prop.replace(/[XYZ]/, "");
176
+ const axis = prop.replace(fn, "");
177
+ const idx = [
96
178
  "X",
97
179
  "Y",
98
180
  "Z"
99
- ].indexOf(r), a = e === "scale" ? 1 : 0, o = e + "Self", c = [
100
- i === 0 ? s : a,
101
- i === 1 ? s : a,
102
- i === 2 ? s : a
181
+ ].indexOf(axis);
182
+ const def = fn === "scale" ? 1 : 0;
183
+ const method = fn + "Self";
184
+ const axeValues = [
185
+ idx === 0 ? x : def,
186
+ idx === 1 ? x : def,
187
+ idx === 2 ? x : def
103
188
  ];
104
- n[o](...c);
189
+ m[method](...axeValues);
105
190
  }
106
- else throw TypeError(i);
107
- }), n;
108
- }, o = (e, t) => t ? [
109
- e.a,
110
- e.b,
111
- e.c,
112
- e.d,
113
- e.e,
114
- e.f
115
- ] : [
116
- e.m11,
117
- e.m12,
118
- e.m13,
119
- e.m14,
120
- e.m21,
121
- e.m22,
122
- e.m23,
123
- e.m24,
124
- e.m31,
125
- e.m32,
126
- e.m33,
127
- e.m34,
128
- e.m41,
129
- e.m42,
130
- e.m43,
131
- e.m44
132
- ], s = (e, t, n) => {
133
- let r = new h();
134
- return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = n, r;
135
- }, c = (e, t, n) => {
136
- 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;
137
- r.m11 = m, r.a = m, r.m12 = g, r.b = g, r.m13 = d;
138
- let _ = l * d * f + c * p;
139
- r.m21 = _, r.c = _;
140
- let v = c * f - l * d * p;
141
- 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;
142
- }, l = (e = 0, t = 0, n = 0, r = 0) => {
143
- let i = new h(), a = Math.sqrt(e * e + t * t + n * n);
144
- if (a === 0) return i;
145
- 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;
146
- i.m11 = _, i.a = _;
147
- let v = 2 * (o * s * f + c * u * d);
148
- i.m12 = v, i.b = v, i.m13 = 2 * (o * c * f - s * u * d);
149
- let y = 2 * (s * o * f - c * u * d);
150
- i.m21 = y, i.c = y;
151
- let b = 1 - 2 * (g + p) * f;
152
- 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;
153
- }, u = (e, t, n) => {
154
- let r = new h();
155
- return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = n, r;
156
- }, d = (e, t) => {
157
- let n = new h();
158
- if (e) {
159
- let t = e * Math.PI / 180, r = Math.tan(t);
160
- n.m21 = r, n.c = r;
191
+ else throw TypeError(invalidStringError);
192
+ });
193
+ return m;
194
+ };
195
+ /**
196
+ * Returns an *Array* containing elements which comprise the matrix.
197
+ * The method can return either the 16 elements or the 6 elements
198
+ * depending on the value of the `is2D` parameter.
199
+ *
200
+ * @param m the source matrix to feed values from.
201
+ * @param is2D *Array* representation of the matrix
202
+ * @return an *Array* representation of the matrix
203
+ */
204
+ const toArray = (m, is2D) => {
205
+ if (is2D) return [
206
+ m.a,
207
+ m.b,
208
+ m.c,
209
+ m.d,
210
+ m.e,
211
+ m.f
212
+ ];
213
+ return [
214
+ m.m11,
215
+ m.m12,
216
+ m.m13,
217
+ m.m14,
218
+ m.m21,
219
+ m.m22,
220
+ m.m23,
221
+ m.m24,
222
+ m.m31,
223
+ m.m32,
224
+ m.m33,
225
+ m.m34,
226
+ m.m41,
227
+ m.m42,
228
+ m.m43,
229
+ m.m44
230
+ ];
231
+ };
232
+ /**
233
+ * Creates a new `CSSMatrix` for the translation matrix and returns it.
234
+ * This method is equivalent to the CSS `translate3d()` function.
235
+ *
236
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate3d
237
+ *
238
+ * @param x the `x-axis` position.
239
+ * @param y the `y-axis` position.
240
+ * @param z the `z-axis` position.
241
+ * @return the resulted matrix.
242
+ */
243
+ const Translate = (x, y, z) => {
244
+ const m = new CSSMatrix();
245
+ m.m41 = x;
246
+ m.e = x;
247
+ m.m42 = y;
248
+ m.f = y;
249
+ m.m43 = z;
250
+ return m;
251
+ };
252
+ /**
253
+ * Creates a new `CSSMatrix` for the rotation matrix and returns it.
254
+ *
255
+ * http://en.wikipedia.org/wiki/Rotation_matrix
256
+ *
257
+ * @param rx the `x-axis` rotation.
258
+ * @param ry the `y-axis` rotation.
259
+ * @param rz the `z-axis` rotation.
260
+ * @return the resulted matrix.
261
+ */
262
+ const Rotate = (rx, ry, rz) => {
263
+ const m = new CSSMatrix();
264
+ const degToRad = Math.PI / 180;
265
+ const radX = rx * degToRad;
266
+ const radY = ry * degToRad;
267
+ const radZ = rz * degToRad;
268
+ const cosx = Math.cos(radX);
269
+ const sinx = -Math.sin(radX);
270
+ const cosy = Math.cos(radY);
271
+ const siny = -Math.sin(radY);
272
+ const cosz = Math.cos(radZ);
273
+ const sinz = -Math.sin(radZ);
274
+ const m11 = cosy * cosz;
275
+ const m12 = -cosy * sinz;
276
+ m.m11 = m11;
277
+ m.a = m11;
278
+ m.m12 = m12;
279
+ m.b = m12;
280
+ m.m13 = siny;
281
+ const m21 = sinx * siny * cosz + cosx * sinz;
282
+ m.m21 = m21;
283
+ m.c = m21;
284
+ const m22 = cosx * cosz - sinx * siny * sinz;
285
+ m.m22 = m22;
286
+ m.d = m22;
287
+ m.m23 = -sinx * cosy;
288
+ m.m31 = sinx * sinz - cosx * siny * cosz;
289
+ m.m32 = sinx * cosz + cosx * siny * sinz;
290
+ m.m33 = cosx * cosy;
291
+ return m;
292
+ };
293
+ /**
294
+ * Creates a new `CSSMatrix` for the rotation matrix and returns it.
295
+ * This method is equivalent to the CSS `rotate3d()` function.
296
+ *
297
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d
298
+ *
299
+ * @param x the `x-axis` vector length.
300
+ * @param y the `y-axis` vector length.
301
+ * @param z the `z-axis` vector length.
302
+ * @param alpha the value in degrees of the rotation.
303
+ * @return the resulted matrix.
304
+ */
305
+ const RotateAxisAngle = (x = 0, y = 0, z = 0, alpha = 0) => {
306
+ const m = new CSSMatrix();
307
+ const length = Math.sqrt(x * x + y * y + z * z);
308
+ if (length === 0) return m;
309
+ const X = x / length;
310
+ const Y = y / length;
311
+ const Z = z / length;
312
+ const angle = alpha * (Math.PI / 360);
313
+ const sinA = Math.sin(angle);
314
+ const cosA = Math.cos(angle);
315
+ const sinA2 = sinA * sinA;
316
+ const x2 = X * X;
317
+ const y2 = Y * Y;
318
+ const z2 = Z * Z;
319
+ const m11 = 1 - 2 * (y2 + z2) * sinA2;
320
+ m.m11 = m11;
321
+ m.a = m11;
322
+ const m12 = 2 * (X * Y * sinA2 + Z * sinA * cosA);
323
+ m.m12 = m12;
324
+ m.b = m12;
325
+ m.m13 = 2 * (X * Z * sinA2 - Y * sinA * cosA);
326
+ const m21 = 2 * (Y * X * sinA2 - Z * sinA * cosA);
327
+ m.m21 = m21;
328
+ m.c = m21;
329
+ const m22 = 1 - 2 * (z2 + x2) * sinA2;
330
+ m.m22 = m22;
331
+ m.d = m22;
332
+ m.m23 = 2 * (Y * Z * sinA2 + X * sinA * cosA);
333
+ m.m31 = 2 * (Z * X * sinA2 + Y * sinA * cosA);
334
+ m.m32 = 2 * (Z * Y * sinA2 - X * sinA * cosA);
335
+ m.m33 = 1 - 2 * (x2 + y2) * sinA2;
336
+ return m;
337
+ };
338
+ /**
339
+ * Creates a new `CSSMatrix` for the scale matrix and returns it.
340
+ * This method is equivalent to the CSS `scale3d()` function, except it doesn't
341
+ * accept {x, y, z} transform origin parameters.
342
+ *
343
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale3d
344
+ *
345
+ * @param x the `x-axis` scale.
346
+ * @param y the `y-axis` scale.
347
+ * @param z the `z-axis` scale.
348
+ * @return the resulted matrix.
349
+ */
350
+ const Scale = (x, y, z) => {
351
+ const m = new CSSMatrix();
352
+ m.m11 = x;
353
+ m.a = x;
354
+ m.m22 = y;
355
+ m.d = y;
356
+ m.m33 = z;
357
+ return m;
358
+ };
359
+ /**
360
+ * Creates a new `CSSMatrix` for the shear of both the `x-axis` and`y-axis`
361
+ * matrix and returns it. This method is equivalent to the CSS `skew()` function.
362
+ *
363
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
364
+ *
365
+ * @param angleX the X-angle in degrees.
366
+ * @param angleY the Y-angle in degrees.
367
+ * @return the resulted matrix.
368
+ */
369
+ const Skew = (angleX, angleY) => {
370
+ const m = new CSSMatrix();
371
+ if (angleX) {
372
+ const radX = angleX * Math.PI / 180;
373
+ const tX = Math.tan(radX);
374
+ m.m21 = tX;
375
+ m.c = tX;
161
376
  }
162
- if (t) {
163
- let e = t * Math.PI / 180, r = Math.tan(e);
164
- n.m12 = r, n.b = r;
377
+ if (angleY) {
378
+ const radY = angleY * Math.PI / 180;
379
+ const tY = Math.tan(radY);
380
+ m.m12 = tY;
381
+ m.b = tY;
165
382
  }
166
- return n;
167
- }, f = (e) => d(e, 0), p = (e) => d(0, e), m = (e, t) => r([
168
- t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41,
169
- t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42,
170
- t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43,
171
- t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44,
172
- t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41,
173
- t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42,
174
- t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43,
175
- t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44,
176
- t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41,
177
- t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42,
178
- t.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43,
179
- t.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44,
180
- t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41,
181
- t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42,
182
- t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43,
183
- t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44
184
- ]), h = class {
185
- static Translate = s;
186
- static Rotate = c;
187
- static RotateAxisAngle = l;
188
- static Scale = u;
189
- static SkewX = f;
190
- static SkewY = p;
191
- static Skew = d;
192
- static Multiply = m;
193
- static fromArray = r;
194
- static fromMatrix = i;
195
- static fromString = a;
196
- static toArray = o;
197
- static isCompatibleArray = t;
198
- static isCompatibleObject = n;
199
- constructor(e) {
200
- 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;
383
+ return m;
384
+ };
385
+ /**
386
+ * Creates a new `CSSMatrix` for the shear of the `x-axis` rotation matrix and
387
+ * returns it. This method is equivalent to the CSS `skewX()` function.
388
+ *
389
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewX
390
+ *
391
+ * @param angle the angle in degrees.
392
+ * @return the resulted matrix.
393
+ */
394
+ const SkewX = (angle) => {
395
+ return Skew(angle, 0);
396
+ };
397
+ /**
398
+ * Creates a new `CSSMatrix` for the shear of the `y-axis` rotation matrix and
399
+ * returns it. This method is equivalent to the CSS `skewY()` function.
400
+ *
401
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewY
402
+ *
403
+ * @param angle the angle in degrees.
404
+ * @return the resulted matrix.
405
+ */
406
+ const SkewY = (angle) => {
407
+ return Skew(0, angle);
408
+ };
409
+ /**
410
+ * Creates a new `CSSMatrix` resulted from the multiplication of two matrixes
411
+ * and returns it. Both matrixes are not changed.
412
+ *
413
+ * @param m1 the first matrix.
414
+ * @param m2 the second matrix.
415
+ * @return the resulted matrix.
416
+ */
417
+ const Multiply = (m1, m2) => {
418
+ const m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41;
419
+ const m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42;
420
+ const m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43;
421
+ const m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44;
422
+ const m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41;
423
+ const m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42;
424
+ const m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43;
425
+ const m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44;
426
+ const m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41;
427
+ const m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42;
428
+ const m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43;
429
+ const m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44;
430
+ const m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41;
431
+ const m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42;
432
+ const m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43;
433
+ const m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44;
434
+ return fromArray([
435
+ m11,
436
+ m12,
437
+ m13,
438
+ m14,
439
+ m21,
440
+ m22,
441
+ m23,
442
+ m24,
443
+ m31,
444
+ m32,
445
+ m33,
446
+ m34,
447
+ m41,
448
+ m42,
449
+ m43,
450
+ m44
451
+ ]);
452
+ };
453
+ /**
454
+ * Creates and returns a new `DOMMatrix` compatible instance
455
+ * with equivalent instance methods.
456
+ *
457
+ * @class CSSMatrix
458
+ *
459
+ * @author thednp <https://github.com/thednp>
460
+ * @link homepage <https://thednp.github.io/dommatrix/>
461
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix
462
+ */
463
+ var CSSMatrix = class {
464
+ /** Returns a new translation matrix. See the `Translate` helper. */
465
+ static Translate = Translate;
466
+ /** Returns a new rotation matrix. See the `Rotate` helper. */
467
+ static Rotate = Rotate;
468
+ /** Returns a new rotation matrix about a vector. See the `RotateAxisAngle` helper. */
469
+ static RotateAxisAngle = RotateAxisAngle;
470
+ /** Returns a new scale matrix. See the `Scale` helper. */
471
+ static Scale = Scale;
472
+ /** Returns a new skew-X matrix. See the `SkewX` helper. */
473
+ static SkewX = SkewX;
474
+ /** Returns a new skew-Y matrix. See the `SkewY` helper. */
475
+ static SkewY = SkewY;
476
+ /** Returns a new skew matrix. See the `Skew` helper. */
477
+ static Skew = Skew;
478
+ /** Returns the multiplication of two matrices. See the `Multiply` helper. */
479
+ static Multiply = Multiply;
480
+ /** Creates a new matrix from an array of 6/16 numbers. See the `fromArray` helper. */
481
+ static fromArray = fromArray;
482
+ /** Creates a new matrix from an existing matrix or a JSON object. See the `fromMatrix` helper. */
483
+ static fromMatrix = fromMatrix;
484
+ /** Creates a new matrix from a CSS transform string. See the `fromString` helper. */
485
+ static fromString = fromString;
486
+ /** Returns an *Array* of 6/16 values from a compatible matrix. See the `toArray` helper. */
487
+ static toArray = toArray;
488
+ /** Checks if a value is a compatible 6/16 number array. See the `isCompatibleArray` helper. */
489
+ static isCompatibleArray = isCompatibleArray;
490
+ /** Checks if a value is a `CSSMatrix` / `DOMMatrix` / `JSONMatrix` object. See the `isCompatibleObject` helper. */
491
+ static isCompatibleObject = isCompatibleObject;
492
+ /**
493
+ * @constructor
494
+ * @param init accepts all parameter configurations:
495
+ * * valid CSS transform string,
496
+ * * CSSMatrix/DOMMatrix instance,
497
+ * * a 6/16 elements *Array*.
498
+ */
499
+ constructor(init) {
500
+ this.a = 1;
501
+ this.b = 0;
502
+ this.c = 0;
503
+ this.d = 1;
504
+ this.e = 0;
505
+ this.f = 0;
506
+ this.m11 = 1;
507
+ this.m12 = 0;
508
+ this.m13 = 0;
509
+ this.m14 = 0;
510
+ this.m21 = 0;
511
+ this.m22 = 1;
512
+ this.m23 = 0;
513
+ this.m24 = 0;
514
+ this.m31 = 0;
515
+ this.m32 = 0;
516
+ this.m33 = 1;
517
+ this.m34 = 0;
518
+ this.m41 = 0;
519
+ this.m42 = 0;
520
+ this.m43 = 0;
521
+ this.m44 = 1;
522
+ if (init) return this.setMatrixValue(init);
523
+ return this;
201
524
  }
525
+ /**
526
+ * A `Boolean` whose value is `true` if the matrix is the identity matrix. The identity
527
+ * matrix is one in which every value is 0 except those on the main diagonal from top-left
528
+ * to bottom-right corner (in other words, where the offsets in each direction are equal).
529
+ *
530
+ * @return the current property value
531
+ */
202
532
  get isIdentity() {
203
533
  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;
204
534
  }
535
+ /**
536
+ * A `Boolean` flag whose value is `true` if the matrix was initialized as a 2D matrix
537
+ * and `false` if the matrix is 3D.
538
+ *
539
+ * @return the current property value
540
+ */
205
541
  get is2D() {
206
542
  return this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;
207
543
  }
208
- setMatrixValue(e) {
209
- 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;
544
+ /**
545
+ * The `setMatrixValue` method replaces the existing matrix with one computed
546
+ * in the browser. EG: `matrix(1,0.25,-0.25,1,0,0)`
547
+ *
548
+ * The method accepts any *Array* values, the result of
549
+ * `DOMMatrix` instance method `toFloat64Array()` / `toFloat32Array()` calls
550
+ * or `CSSMatrix` instance method `toArray()`.
551
+ *
552
+ * This method expects valid *matrix()* / *matrix3d()* string values, as well
553
+ * as other transform functions like *translateX(10px)*.
554
+ *
555
+ * @param source
556
+ * @return the matrix instance
557
+ */
558
+ setMatrixValue(source) {
559
+ if (typeof source === "string" && source.length && source !== "none") return fromString(source);
560
+ if (Array.isArray(source) || source instanceof Float64Array || source instanceof Float32Array) return fromArray(source);
561
+ if (typeof source === "object") return fromMatrix(source);
562
+ return this;
210
563
  }
211
- toFloat32Array(e) {
212
- return Float32Array.from(o(this, e));
564
+ /**
565
+ * Returns a *Float32Array* containing elements which comprise the matrix.
566
+ * The method can return either the 16 elements or the 6 elements
567
+ * depending on the value of the `is2D` parameter.
568
+ *
569
+ * @param is2D *Array* representation of the matrix
570
+ * @return an *Array* representation of the matrix
571
+ */
572
+ toFloat32Array(is2D) {
573
+ return Float32Array.from(toArray(this, is2D));
213
574
  }
214
- toFloat64Array(e) {
215
- return Float64Array.from(o(this, e));
575
+ /**
576
+ * Returns a *Float64Array* containing elements which comprise the matrix.
577
+ * The method can return either the 16 elements or the 6 elements
578
+ * depending on the value of the `is2D` parameter.
579
+ *
580
+ * @param is2D *Array* representation of the matrix
581
+ * @return an *Array* representation of the matrix
582
+ */
583
+ toFloat64Array(is2D) {
584
+ return Float64Array.from(toArray(this, is2D));
216
585
  }
586
+ /**
587
+ * Creates and returns a string representation of the matrix in `CSS` matrix syntax,
588
+ * using the appropriate `CSS` matrix notation.
589
+ *
590
+ * matrix3d *matrix3d(m11, m12, m13, m14, m21, ...)*
591
+ * matrix *matrix(a, b, c, d, e, f)*
592
+ *
593
+ * @return a string representation of the matrix
594
+ */
217
595
  toString() {
218
- let { is2D: e } = this, t = this.toFloat64Array(e).join(", ");
219
- return `${e ? "matrix" : "matrix3d"}(${t})`;
596
+ const { is2D } = this;
597
+ const values = this.toFloat64Array(is2D).join(", ");
598
+ return `${is2D ? "matrix" : "matrix3d"}(${values})`;
220
599
  }
600
+ /**
601
+ * Returns a JSON representation of the `CSSMatrix` instance, a standard *Object*
602
+ * that includes `{a,b,c,d,e,f}` and `{m11,m12,m13,..m44}` properties as well
603
+ * as the `is2D` & `isIdentity` properties.
604
+ *
605
+ * The result can also be used as a second parameter for the `fromMatrix` static method
606
+ * to load values into another matrix instance.
607
+ *
608
+ * @return an *Object* with all matrix values.
609
+ */
221
610
  toJSON() {
222
- let { is2D: e, isIdentity: t } = this;
611
+ const { is2D, isIdentity } = this;
223
612
  return {
224
613
  ...this,
225
- is2D: e,
226
- isIdentity: t
614
+ is2D,
615
+ isIdentity
227
616
  };
228
617
  }
229
- multiply(e) {
230
- return m(this, e);
618
+ /**
619
+ * The Multiply method returns a new CSSMatrix which is the result of this
620
+ * matrix multiplied by the passed matrix, with the passed matrix to the right.
621
+ * This matrix is not modified.
622
+ *
623
+ * @param m2 CSSMatrix
624
+ * @return The resulted matrix.
625
+ */
626
+ multiply(m2) {
627
+ return Multiply(this, m2);
231
628
  }
232
- translate(e, t, n) {
233
- return this.multiply(s(e, t ?? 0, n ?? 0));
629
+ /**
630
+ * The translate method returns a new matrix which is this matrix post
631
+ * multiplied by a translation matrix containing the passed values. If the z
632
+ * component is undefined, a 0 value is used in its place. This matrix is not
633
+ * modified.
634
+ *
635
+ * @param x X component of the translation value.
636
+ * @param y Y component of the translation value.
637
+ * @param z Z component of the translation value.
638
+ * @return The resulted matrix
639
+ */
640
+ translate(x, y, z) {
641
+ return this.multiply(Translate(x, y ?? 0, z ?? 0));
234
642
  }
235
- scale(e, t, n) {
236
- return this.multiply(u(e, t ?? e, n ?? 1));
643
+ /**
644
+ * The scale method returns a new matrix which is this matrix post multiplied by
645
+ * a scale matrix containing the passed values. If the z component is undefined,
646
+ * a 1 value is used in its place. If the y component is undefined, the x
647
+ * component value is used in its place. This matrix is not modified.
648
+ *
649
+ * @param x The X component of the scale value.
650
+ * @param y The Y component of the scale value.
651
+ * @param z The Z component of the scale value.
652
+ * @return The resulted matrix
653
+ */
654
+ scale(x, y, z) {
655
+ return this.multiply(Scale(x, y ?? x, z ?? 1));
237
656
  }
238
- rotate(e, t, n) {
239
- let r = e, i = t || 0, a = n || 0;
240
- return typeof e == "number" && t === void 0 && n === void 0 && (a = r, r = 0, i = 0), this.multiply(c(r, i, a));
657
+ /**
658
+ * The rotate method returns a new matrix which is this matrix post multiplied
659
+ * by each of 3 rotation matrices about the major axes, first X, then Y, then Z.
660
+ * If the y and z components are undefined, the x value is used to rotate the
661
+ * object about the z axis, as though the vector (0,0,x) were passed. All
662
+ * rotation values are in degrees. This matrix is not modified.
663
+ *
664
+ * @param rx The X component of the rotation, or Z if Y and Z are null.
665
+ * @param ry The (optional) Y component of the rotation value.
666
+ * @param rz The (optional) Z component of the rotation value.
667
+ * @return The resulted matrix
668
+ */
669
+ rotate(rx, ry, rz) {
670
+ let RX = rx;
671
+ let RY = ry || 0;
672
+ let RZ = rz || 0;
673
+ if (typeof rx === "number" && typeof ry === "undefined" && typeof rz === "undefined") {
674
+ RZ = RX;
675
+ RX = 0;
676
+ RY = 0;
677
+ }
678
+ return this.multiply(Rotate(RX, RY, RZ));
241
679
  }
242
- rotateAxisAngle(e = 0, t = 0, n = 0, r = 0) {
680
+ /**
681
+ * The rotateAxisAngle method returns a new matrix which is this matrix post
682
+ * multiplied by a rotation matrix with the given axis and `angle`. The right-hand
683
+ * rule is used to determine the direction of rotation. All rotation values are
684
+ * in degrees. This matrix is not modified.
685
+ *
686
+ * @param x The X component of the axis vector.
687
+ * @param y The Y component of the axis vector.
688
+ * @param z The Z component of the axis vector.
689
+ * @param angle The angle of rotation about the axis vector, in degrees.
690
+ * @return The resulted matrix
691
+ */
692
+ rotateAxisAngle(x = 0, y = 0, z = 0, angle = 0) {
243
693
  if ([
244
- e,
245
- t,
246
- n,
247
- r
248
- ].some((e) => !Number.isFinite(e))) throw TypeError("CSSMatrix: expecting 4 values");
249
- return Math.sqrt(e * e + t * t + n * n) === 0 ? i(this) : this.multiply(l(e, t, n, r));
694
+ x,
695
+ y,
696
+ z,
697
+ angle
698
+ ].some((n) => !Number.isFinite(n))) throw new TypeError("CSSMatrix: expecting 4 values");
699
+ if (Math.sqrt(x * x + y * y + z * z) === 0) return fromMatrix(this);
700
+ return this.multiply(RotateAxisAngle(x, y, z, angle));
250
701
  }
251
- skewX(e) {
252
- return this.multiply(f(e));
702
+ /**
703
+ * Specifies a skew transformation along the `x-axis` by the given angle.
704
+ * This matrix is not modified.
705
+ *
706
+ * @param angle The angle amount in degrees to skew.
707
+ * @return The resulted matrix
708
+ */
709
+ skewX(angle) {
710
+ return this.multiply(SkewX(angle));
253
711
  }
254
- skewY(e) {
255
- return this.multiply(p(e));
712
+ /**
713
+ * Specifies a skew transformation along the `y-axis` by the given angle.
714
+ * This matrix is not modified.
715
+ *
716
+ * @param angle The angle amount in degrees to skew.
717
+ * @return The resulted matrix
718
+ */
719
+ skewY(angle) {
720
+ return this.multiply(SkewY(angle));
256
721
  }
257
- skew(e, t) {
258
- return this.multiply(d(e, t));
722
+ /**
723
+ * Specifies a skew transformation along both the `x-axis` and `y-axis`.
724
+ * This matrix is not modified.
725
+ *
726
+ * @param angleX The X-angle amount in degrees to skew.
727
+ * @param angleY The angle amount in degrees to skew.
728
+ * @return The resulted matrix
729
+ */
730
+ skew(angleX, angleY) {
731
+ return this.multiply(Skew(angleX, angleY));
259
732
  }
260
- multiplySelf(e) {
261
- let t = m(this, e);
262
- return Object.assign(this, t), this;
733
+ /**
734
+ * Modifies the current matrix by post-multiplying it with another matrix.
735
+ * This is the mutable version of multiply().
736
+ *
737
+ * @param m2 The matrix to multiply with
738
+ * @return this matrix (modified)
739
+ */
740
+ multiplySelf(m2) {
741
+ const result = Multiply(this, m2);
742
+ Object.assign(this, result);
743
+ return this;
263
744
  }
264
- translateSelf(e, t, n) {
265
- return this.multiplySelf(s(e, t ?? 0, n ?? 0));
745
+ /**
746
+ * Modifies the current matrix by post-multiplying it with a translation matrix.
747
+ * This is the mutable version of translate().
748
+ *
749
+ * @param x X component of the translation value.
750
+ * @param y Y component of the translation value.
751
+ * @param z Z component of the translation value.
752
+ * @return this matrix (modified)
753
+ */
754
+ translateSelf(x, y, z) {
755
+ return this.multiplySelf(Translate(x, y ?? 0, z ?? 0));
266
756
  }
267
- scaleSelf(e, t, n) {
268
- return this.multiplySelf(u(e, t ?? e, n ?? 1));
757
+ /**
758
+ * Modifies the current matrix by post-multiplying it with a scale matrix.
759
+ * This is the mutable version of scale().
760
+ *
761
+ * @param x The X component of the scale value.
762
+ * @param y The Y component of the scale value.
763
+ * @param z The Z component of the scale value.
764
+ * @return this matrix (modified)
765
+ */
766
+ scaleSelf(x, y, z) {
767
+ return this.multiplySelf(Scale(x, y ?? x, z ?? 1));
269
768
  }
270
- rotateSelf(e, t, n) {
271
- let r = e, i = t || 0, a = n || 0;
272
- return typeof e == "number" && t === void 0 && n === void 0 && (a = r, r = 0, i = 0), this.multiplySelf(c(r, i, a));
769
+ /**
770
+ * Modifies the current matrix by post-multiplying it with a rotation matrix.
771
+ * This is the mutable version of rotate().
772
+ *
773
+ * @param rx The X component of the rotation, or Z if Y and Z are null.
774
+ * @param ry The (optional) Y component of the rotation value.
775
+ * @param rz The (optional) Z component of the rotation value.
776
+ * @return this matrix (modified)
777
+ */
778
+ rotateSelf(rx, ry, rz) {
779
+ let RX = rx;
780
+ let RY = ry || 0;
781
+ let RZ = rz || 0;
782
+ if (typeof rx === "number" && typeof ry === "undefined" && typeof rz === "undefined") {
783
+ RZ = RX;
784
+ RX = 0;
785
+ RY = 0;
786
+ }
787
+ return this.multiplySelf(Rotate(RX, RY, RZ));
273
788
  }
274
- rotateAxisAngleSelf(e = 0, t = 0, n = 0, r = 0) {
789
+ /**
790
+ * Modifies the current matrix by post-multiplying it with a rotation matrix
791
+ * with the given axis and angle.
792
+ * This is the mutable version of rotateAxisAngle().
793
+ *
794
+ * @param x The X component of the axis vector.
795
+ * @param y The Y component of the axis vector.
796
+ * @param z The Z component of the axis vector.
797
+ * @param angle The angle of rotation about the axis vector, in degrees.
798
+ * @return this matrix (modified)
799
+ */
800
+ rotateAxisAngleSelf(x = 0, y = 0, z = 0, angle = 0) {
275
801
  if ([
276
- e,
277
- t,
278
- n,
279
- r
280
- ].some((e) => !Number.isFinite(e))) throw TypeError("CSSMatrix: expecting 4 values");
281
- return Math.sqrt(e * e + t * t + n * n) === 0 ? this : this.multiplySelf(l(e, t, n, r));
802
+ x,
803
+ y,
804
+ z,
805
+ angle
806
+ ].some((n) => !Number.isFinite(n))) throw new TypeError("CSSMatrix: expecting 4 values");
807
+ if (Math.sqrt(x * x + y * y + z * z) === 0) return this;
808
+ return this.multiplySelf(RotateAxisAngle(x, y, z, angle));
282
809
  }
283
- skewXSelf(e) {
284
- return this.multiplySelf(f(e));
810
+ /**
811
+ * Modifies the current matrix by post-multiplying it with a skewX matrix.
812
+ * This is the mutable version of skewX().
813
+ *
814
+ * @param angle The angle amount in degrees to skew.
815
+ * @return this matrix (modified)
816
+ */
817
+ skewXSelf(angle) {
818
+ return this.multiplySelf(SkewX(angle));
285
819
  }
286
- skewYSelf(e) {
287
- return this.multiplySelf(p(e));
820
+ /**
821
+ * Modifies the current matrix by post-multiplying it with a skewY matrix.
822
+ * This is the mutable version of skewY().
823
+ *
824
+ * @param angle The angle amount in degrees to skew.
825
+ * @return this matrix (modified)
826
+ */
827
+ skewYSelf(angle) {
828
+ return this.multiplySelf(SkewY(angle));
288
829
  }
289
- skewSelf(e, t) {
290
- return this.multiplySelf(d(e, t));
830
+ /**
831
+ * Modifies the current matrix by post-multiplying it with a skew matrix.
832
+ * This is the mutable version of skew().
833
+ *
834
+ * @param angleX The X-angle amount in degrees to skew.
835
+ * @param angleY The Y-angle amount in degrees to skew.
836
+ * @return this matrix (modified)
837
+ */
838
+ skewSelf(angleX, angleY) {
839
+ return this.multiplySelf(Skew(angleX, angleY));
291
840
  }
292
- transformPoint(e) {
293
- 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;
294
- return e instanceof DOMPoint ? new DOMPoint(t, n, r, i) : {
295
- x: t,
296
- y: n,
297
- z: r,
298
- w: i
841
+ /**
842
+ * Transforms a specified vector using the matrix, returning a new
843
+ * {x,y,z,w} Tuple *Object* comprising the transformed vector.
844
+ * Neither the matrix nor the original vector are altered.
845
+ *
846
+ * The method is equivalent with `transformPoint()` method
847
+ * of the `DOMMatrix` constructor.
848
+ *
849
+ * @param t Tuple with `{x,y,z,w}` components
850
+ * @return the resulting Tuple
851
+ */
852
+ transformPoint(t) {
853
+ const x = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w;
854
+ const y = this.m12 * t.x + this.m22 * t.y + this.m32 * t.z + this.m42 * t.w;
855
+ const z = this.m13 * t.x + this.m23 * t.y + this.m33 * t.z + this.m43 * t.w;
856
+ const w = this.m14 * t.x + this.m24 * t.y + this.m34 * t.z + this.m44 * t.w;
857
+ return typeof DOMPoint !== "undefined" && t instanceof DOMPoint ? new DOMPoint(x, y, z, w) : {
858
+ x,
859
+ y,
860
+ z,
861
+ w
299
862
  };
300
863
  }
301
864
  };
302
865
  //#endregion
303
- export { h as default };
866
+ export { CSSMatrix as default };
304
867
 
305
868
  //# sourceMappingURL=dommatrix.mjs.map