@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,538 +1,305 @@
1
- const I = {
2
- a: 1,
3
- b: 0,
4
- c: 0,
5
- d: 1,
6
- e: 0,
7
- f: 0,
8
- m11: 1,
9
- m12: 0,
10
- m13: 0,
11
- m14: 0,
12
- m21: 0,
13
- m22: 1,
14
- m23: 0,
15
- m24: 0,
16
- m31: 0,
17
- m32: 0,
18
- m33: 1,
19
- m34: 0,
20
- m41: 0,
21
- m42: 0,
22
- m43: 0,
23
- m44: 1,
24
- is2D: !0,
25
- isIdentity: !0
26
- }, T = (s) => (s instanceof Float64Array || s instanceof Float32Array || Array.isArray(s) && s.every((t) => typeof t == "number")) && [6, 16].some((t) => s.length === t), E = (s) => s instanceof DOMMatrix || s instanceof M || typeof s == "object" && Object.keys(I).every((t) => s && t in s), b = (s) => {
27
- const t = new M(), e = Array.from(s);
28
- if (!T(e))
29
- throw TypeError(
30
- `CSSMatrix: "${e.join(",")}" must be an array with 6/16 numbers.`
31
- );
32
- if (e.length === 16) {
33
- const [
34
- i,
35
- n,
36
- m,
37
- a,
38
- h,
39
- r,
40
- l,
41
- c,
42
- u,
43
- f,
44
- p,
45
- o,
46
- y,
47
- S,
48
- d,
49
- w
50
- ] = e;
51
- 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 = S, t.f = S, t.m13 = m, t.m23 = l, t.m33 = p, t.m43 = d, t.m14 = a, t.m24 = c, t.m34 = o, t.m44 = w;
52
- } else if (e.length === 6) {
53
- const [i, n, m, a, h, r] = e;
54
- 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;
55
- }
56
- return t;
57
- }, N = (s) => {
58
- if (E(s))
59
- return b([
60
- s.m11,
61
- s.m12,
62
- s.m13,
63
- s.m14,
64
- s.m21,
65
- s.m22,
66
- s.m23,
67
- s.m24,
68
- s.m31,
69
- s.m32,
70
- s.m33,
71
- s.m34,
72
- s.m41,
73
- s.m42,
74
- s.m43,
75
- s.m44
76
- ]);
77
- throw TypeError(
78
- `CSSMatrix: "${JSON.stringify(
79
- s
80
- )}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`
81
- );
82
- }, R = (s) => {
83
- if (typeof s != "string")
84
- throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a string.`);
85
- const t = String(s).replace(/\s/g, ""), e = new M(), i = `CSSMatrix: invalid transform string "${s}"`;
86
- return t.split(")").filter((n) => n).forEach((n) => {
87
- const [m, a] = n.split("(");
88
- if (!a) throw TypeError(i);
89
- const h = a.split(",").map(
90
- (o) => o.includes("rad") ? parseFloat(o) * (180 / Math.PI) : parseFloat(o)
91
- ), [r, l, c, u] = h, f = [r, l, c], p = [r, l, c, u];
92
- if (m === "perspective" && r && [l, c].every((o) => o === void 0))
93
- e.m34 = -1 / r;
94
- else if (m.includes("matrix") && [6, 16].includes(h.length) && h.every((o) => !Number.isNaN(+o))) {
95
- const o = h.map((y) => Math.abs(y) < 1e-6 ? 0 : y);
96
- e.multiplySelf(b(o));
97
- } else if (m === "translate3d" && f.every((o) => !Number.isNaN(+o)))
98
- e.translateSelf(r, l, c);
99
- else if (m === "translate" && r && c === void 0)
100
- e.translateSelf(r, l || 0, 0);
101
- else if (m === "rotate3d" && p.every((o) => !Number.isNaN(+o)) && u)
102
- e.rotateAxisAngleSelf(r, l, c, u);
103
- else if (m === "rotate" && r && [l, c].every((o) => o === void 0))
104
- e.rotateSelf(0, 0, r);
105
- else if (m === "scale3d" && f.every((o) => !Number.isNaN(+o)) && f.some((o) => o !== 1))
106
- e.scaleSelf(r, l, c);
107
- else if (
108
- // prop === "scale" && !Number.isNaN(x) && x !== 1 && z === undefined
109
- // prop === "scale" && !Number.isNaN(x) && [x, y].some((n) => n !== 1) &&
110
- m === "scale" && !Number.isNaN(r) && (r !== 1 || l !== 1) && c === void 0
111
- ) {
112
- const y = Number.isNaN(+l) ? r : l;
113
- e.scaleSelf(r, y, 1);
114
- } else if (m === "skew" && (r || !Number.isNaN(r) && l) && c === void 0)
115
- e.skewSelf(r, l || 0);
116
- else if (["translate", "rotate", "scale", "skew"].some(
117
- (o) => m.includes(o)
118
- ) && /[XYZ]/.test(m) && r && [l, c].every((o) => o === void 0))
119
- if (m === "skewX" || m === "skewY")
120
- e[m === "skewX" ? "skewXSelf" : "skewYSelf"](r);
121
- else {
122
- const o = m.replace(/[XYZ]/, ""), y = m.replace(o, ""), S = ["X", "Y", "Z"].indexOf(y), d = o === "scale" ? 1 : 0, w = o + "Self", g = [
123
- S === 0 ? r : d,
124
- S === 1 ? r : d,
125
- S === 2 ? r : d
126
- ];
127
- e[w](...g);
128
- }
129
- else
130
- throw TypeError(i);
131
- }), e;
132
- }, x = (s, t) => t ? [s.a, s.b, s.c, s.d, s.e, s.f] : [
133
- s.m11,
134
- s.m12,
135
- s.m13,
136
- s.m14,
137
- s.m21,
138
- s.m22,
139
- s.m23,
140
- s.m24,
141
- s.m31,
142
- s.m32,
143
- s.m33,
144
- s.m34,
145
- s.m41,
146
- s.m42,
147
- s.m43,
148
- s.m44
149
- ], v = (s, t, e) => {
150
- const i = new M();
151
- return i.m41 = s, i.e = s, i.m42 = t, i.f = t, i.m43 = e, i;
152
- }, k = (s, t, e) => {
153
- 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), p = -Math.sin(h), o = c * f, y = -c * p;
154
- i.m11 = o, i.a = o, i.m12 = y, i.b = y, i.m13 = u;
155
- const S = l * u * f + r * p;
156
- i.m21 = S, i.c = S;
157
- const d = r * f - l * u * p;
158
- return i.m22 = d, i.d = d, i.m23 = -l * c, i.m31 = l * p - r * u * f, i.m32 = l * f + r * u * p, i.m33 = r * c, i;
159
- }, X = (s = 0, t = 0, e = 0, i = 0) => {
160
- const n = new M(), m = Math.sqrt(s * s + t * t + e * e);
161
- if (m === 0)
162
- return n;
163
- 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, p = a * a, o = h * h, y = r * r, S = 1 - 2 * (o + y) * f;
164
- n.m11 = S, n.a = S;
165
- const d = 2 * (a * h * f + r * c * u);
166
- n.m12 = d, n.b = d, n.m13 = 2 * (a * r * f - h * c * u);
167
- const w = 2 * (h * a * f - r * c * u);
168
- n.m21 = w, n.c = w;
169
- const g = 1 - 2 * (y + p) * f;
170
- 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 * (p + o) * f, n;
171
- }, O = (s, t, e) => {
172
- const i = new M();
173
- return i.m11 = s, i.a = s, i.m22 = t, i.d = t, i.m33 = e, i;
174
- }, A = (s, t) => {
175
- const e = new M();
176
- if (s) {
177
- const i = s * Math.PI / 180, n = Math.tan(i);
178
- e.m21 = n, e.c = n;
179
- }
180
- if (t) {
181
- const i = t * Math.PI / 180, n = Math.tan(i);
182
- e.m12 = n, e.b = n;
183
- }
184
- return e;
185
- }, Y = (s) => A(s, 0), F = (s) => A(0, s), C = (s, t) => {
186
- 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, p = 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, S = 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;
187
- return b([
188
- e,
189
- i,
190
- n,
191
- m,
192
- a,
193
- h,
194
- r,
195
- l,
196
- c,
197
- u,
198
- f,
199
- p,
200
- o,
201
- y,
202
- S,
203
- d
204
- ]);
1
+ //#region src/index.ts
2
+ var e = {
3
+ a: 1,
4
+ b: 0,
5
+ c: 0,
6
+ d: 1,
7
+ e: 0,
8
+ f: 0,
9
+ m11: 1,
10
+ m12: 0,
11
+ m13: 0,
12
+ m14: 0,
13
+ m21: 0,
14
+ m22: 1,
15
+ m23: 0,
16
+ m24: 0,
17
+ m31: 0,
18
+ m32: 0,
19
+ m33: 1,
20
+ m34: 0,
21
+ m41: 0,
22
+ m42: 0,
23
+ m43: 0,
24
+ 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.`);
30
+ // 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;
37
+ }
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
57
+ ]);
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
74
+ ];
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);
88
+ else if ([
89
+ "translate",
90
+ "rotate",
91
+ "scale",
92
+ "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);
94
+ else {
95
+ let e = t.replace(/[XYZ]/, ""), r = t.replace(e, ""), i = [
96
+ "X",
97
+ "Y",
98
+ "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
103
+ ];
104
+ n[o](...c);
105
+ }
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;
161
+ }
162
+ if (t) {
163
+ let e = t * Math.PI / 180, r = Math.tan(e);
164
+ n.m12 = r, n.b = r;
165
+ }
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;
201
+ }
202
+ get isIdentity() {
203
+ 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
+ }
205
+ get is2D() {
206
+ return this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;
207
+ }
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;
210
+ }
211
+ toFloat32Array(e) {
212
+ return Float32Array.from(o(this, e));
213
+ }
214
+ toFloat64Array(e) {
215
+ return Float64Array.from(o(this, e));
216
+ }
217
+ toString() {
218
+ let { is2D: e } = this, t = this.toFloat64Array(e).join(", ");
219
+ return `${e ? "matrix" : "matrix3d"}(${t})`;
220
+ }
221
+ toJSON() {
222
+ let { is2D: e, isIdentity: t } = this;
223
+ return {
224
+ ...this,
225
+ is2D: e,
226
+ isIdentity: t
227
+ };
228
+ }
229
+ multiply(e) {
230
+ return m(this, e);
231
+ }
232
+ translate(e, t, n) {
233
+ return this.multiply(s(e, t ?? 0, n ?? 0));
234
+ }
235
+ scale(e, t, n) {
236
+ return this.multiply(u(e, t ?? e, n ?? 1));
237
+ }
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));
241
+ }
242
+ rotateAxisAngle(e = 0, t = 0, n = 0, r = 0) {
243
+ 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));
250
+ }
251
+ skewX(e) {
252
+ return this.multiply(f(e));
253
+ }
254
+ skewY(e) {
255
+ return this.multiply(p(e));
256
+ }
257
+ skew(e, t) {
258
+ return this.multiply(d(e, t));
259
+ }
260
+ multiplySelf(e) {
261
+ let t = m(this, e);
262
+ return Object.assign(this, t), this;
263
+ }
264
+ translateSelf(e, t, n) {
265
+ return this.multiplySelf(s(e, t ?? 0, n ?? 0));
266
+ }
267
+ scaleSelf(e, t, n) {
268
+ return this.multiplySelf(u(e, t ?? e, n ?? 1));
269
+ }
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));
273
+ }
274
+ rotateAxisAngleSelf(e = 0, t = 0, n = 0, r = 0) {
275
+ 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));
282
+ }
283
+ skewXSelf(e) {
284
+ return this.multiplySelf(f(e));
285
+ }
286
+ skewYSelf(e) {
287
+ return this.multiplySelf(p(e));
288
+ }
289
+ skewSelf(e, t) {
290
+ return this.multiplySelf(d(e, t));
291
+ }
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
299
+ };
300
+ }
205
301
  };
206
- class M {
207
- static Translate = v;
208
- static Rotate = k;
209
- static RotateAxisAngle = X;
210
- static Scale = O;
211
- static SkewX = Y;
212
- static SkewY = F;
213
- static Skew = A;
214
- static Multiply = C;
215
- static fromArray = b;
216
- static fromMatrix = N;
217
- static fromString = R;
218
- static toArray = x;
219
- static isCompatibleArray = T;
220
- static isCompatibleObject = E;
221
- /**
222
- * @constructor
223
- * @param init accepts all parameter configurations:
224
- * * valid CSS transform string,
225
- * * CSSMatrix/DOMMatrix instance,
226
- * * a 6/16 elements *Array*.
227
- */
228
- constructor(t) {
229
- 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;
230
- }
231
- /**
232
- * A `Boolean` whose value is `true` if the matrix is the identity matrix. The identity
233
- * matrix is one in which every value is 0 except those on the main diagonal from top-left
234
- * to bottom-right corner (in other words, where the offsets in each direction are equal).
235
- *
236
- * @return the current property value
237
- */
238
- get isIdentity() {
239
- 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;
240
- }
241
- /**
242
- * A `Boolean` flag whose value is `true` if the matrix was initialized as a 2D matrix
243
- * and `false` if the matrix is 3D.
244
- *
245
- * @return the current property value
246
- */
247
- get is2D() {
248
- return this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;
249
- }
250
- /**
251
- * The `setMatrixValue` method replaces the existing matrix with one computed
252
- * in the browser. EG: `matrix(1,0.25,-0.25,1,0,0)`
253
- *
254
- * The method accepts any *Array* values, the result of
255
- * `DOMMatrix` instance method `toFloat64Array()` / `toFloat32Array()` calls
256
- * or `CSSMatrix` instance method `toArray()`.
257
- *
258
- * This method expects valid *matrix()* / *matrix3d()* string values, as well
259
- * as other transform functions like *translateX(10px)*.
260
- *
261
- * @param source
262
- * @return the matrix instance
263
- */
264
- setMatrixValue(t) {
265
- return typeof t == "string" && t.length && t !== "none" ? R(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? b(t) : typeof t == "object" ? N(t) : this;
266
- }
267
- /**
268
- * Returns a *Float32Array* containing elements which comprise the matrix.
269
- * The method can return either the 16 elements or the 6 elements
270
- * depending on the value of the `is2D` parameter.
271
- *
272
- * @param is2D *Array* representation of the matrix
273
- * @return an *Array* representation of the matrix
274
- */
275
- toFloat32Array(t) {
276
- return Float32Array.from(x(this, t));
277
- }
278
- /**
279
- * Returns a *Float64Array* containing elements which comprise the matrix.
280
- * The method can return either the 16 elements or the 6 elements
281
- * depending on the value of the `is2D` parameter.
282
- *
283
- * @param is2D *Array* representation of the matrix
284
- * @return an *Array* representation of the matrix
285
- */
286
- toFloat64Array(t) {
287
- return Float64Array.from(x(this, t));
288
- }
289
- /**
290
- * Creates and returns a string representation of the matrix in `CSS` matrix syntax,
291
- * using the appropriate `CSS` matrix notation.
292
- *
293
- * matrix3d *matrix3d(m11, m12, m13, m14, m21, ...)*
294
- * matrix *matrix(a, b, c, d, e, f)*
295
- *
296
- * @return a string representation of the matrix
297
- */
298
- toString() {
299
- const { is2D: t } = this, e = this.toFloat64Array(t).join(", ");
300
- return `${t ? "matrix" : "matrix3d"}(${e})`;
301
- }
302
- /**
303
- * Returns a JSON representation of the `CSSMatrix` instance, a standard *Object*
304
- * that includes `{a,b,c,d,e,f}` and `{m11,m12,m13,..m44}` properties as well
305
- * as the `is2D` & `isIdentity` properties.
306
- *
307
- * The result can also be used as a second parameter for the `fromMatrix` static method
308
- * to load values into another matrix instance.
309
- *
310
- * @return an *Object* with all matrix values.
311
- */
312
- toJSON() {
313
- const { is2D: t, isIdentity: e } = this;
314
- return { ...this, is2D: t, isIdentity: e };
315
- }
316
- /**
317
- * The Multiply method returns a new CSSMatrix which is the result of this
318
- * matrix multiplied by the passed matrix, with the passed matrix to the right.
319
- * This matrix is not modified.
320
- *
321
- * @param m2 CSSMatrix
322
- * @return The resulted matrix.
323
- */
324
- multiply(t) {
325
- return C(this, t);
326
- }
327
- /**
328
- * The translate method returns a new matrix which is this matrix post
329
- * multiplied by a translation matrix containing the passed values. If the z
330
- * component is undefined, a 0 value is used in its place. This matrix is not
331
- * modified.
332
- *
333
- * @param x X component of the translation value.
334
- * @param y Y component of the translation value.
335
- * @param z Z component of the translation value.
336
- * @return The resulted matrix
337
- */
338
- translate(t, e, i) {
339
- return this.multiply(v(t, e ?? 0, i ?? 0));
340
- }
341
- /**
342
- * The scale method returns a new matrix which is this matrix post multiplied by
343
- * a scale matrix containing the passed values. If the z component is undefined,
344
- * a 1 value is used in its place. If the y component is undefined, the x
345
- * component value is used in its place. This matrix is not modified.
346
- *
347
- * @param x The X component of the scale value.
348
- * @param y The Y component of the scale value.
349
- * @param z The Z component of the scale value.
350
- * @return The resulted matrix
351
- */
352
- scale(t, e, i) {
353
- return this.multiply(O(t, e ?? t, i ?? 1));
354
- }
355
- /**
356
- * The rotate method returns a new matrix which is this matrix post multiplied
357
- * by each of 3 rotation matrices about the major axes, first X, then Y, then Z.
358
- * If the y and z components are undefined, the x value is used to rotate the
359
- * object about the z axis, as though the vector (0,0,x) were passed. All
360
- * rotation values are in degrees. This matrix is not modified.
361
- *
362
- * @param rx The X component of the rotation, or Z if Y and Z are null.
363
- * @param ry The (optional) Y component of the rotation value.
364
- * @param rz The (optional) Z component of the rotation value.
365
- * @return The resulted matrix
366
- */
367
- rotate(t, e, i) {
368
- let n = t, m = e || 0, a = i || 0;
369
- return typeof t == "number" && typeof e > "u" && typeof i > "u" && (a = n, n = 0, m = 0), this.multiply(k(n, m, a));
370
- }
371
- /**
372
- * The rotateAxisAngle method returns a new matrix which is this matrix post
373
- * multiplied by a rotation matrix with the given axis and `angle`. The right-hand
374
- * rule is used to determine the direction of rotation. All rotation values are
375
- * in degrees. This matrix is not modified.
376
- *
377
- * @param x The X component of the axis vector.
378
- * @param y The Y component of the axis vector.
379
- * @param z The Z component of the axis vector.
380
- * @param angle The angle of rotation about the axis vector, in degrees.
381
- * @return The resulted matrix
382
- */
383
- rotateAxisAngle(t = 0, e = 0, i = 0, n = 0) {
384
- if ([t, e, i, n].some((a) => !Number.isFinite(a)))
385
- throw new TypeError("CSSMatrix: expecting 4 values");
386
- return Math.sqrt(t * t + e * e + i * i) === 0 ? N(this) : this.multiply(X(t, e, i, n));
387
- }
388
- /**
389
- * Specifies a skew transformation along the `x-axis` by the given angle.
390
- * This matrix is not modified.
391
- *
392
- * @param angle The angle amount in degrees to skew.
393
- * @return The resulted matrix
394
- */
395
- skewX(t) {
396
- return this.multiply(Y(t));
397
- }
398
- /**
399
- * Specifies a skew transformation along the `y-axis` by the given angle.
400
- * This matrix is not modified.
401
- *
402
- * @param angle The angle amount in degrees to skew.
403
- * @return The resulted matrix
404
- */
405
- skewY(t) {
406
- return this.multiply(F(t));
407
- }
408
- /**
409
- * Specifies a skew transformation along both the `x-axis` and `y-axis`.
410
- * This matrix is not modified.
411
- *
412
- * @param angleX The X-angle amount in degrees to skew.
413
- * @param angleY The angle amount in degrees to skew.
414
- * @return The resulted matrix
415
- */
416
- skew(t, e) {
417
- return this.multiply(A(t, e));
418
- }
419
- /**
420
- * Modifies the current matrix by post-multiplying it with another matrix.
421
- * This is the mutable version of multiply().
422
- *
423
- * @param m2 The matrix to multiply with
424
- * @return this matrix (modified)
425
- */
426
- multiplySelf(t) {
427
- const e = C(this, t);
428
- return Object.assign(this, e), this;
429
- }
430
- /**
431
- * Modifies the current matrix by post-multiplying it with a translation matrix.
432
- * This is the mutable version of translate().
433
- *
434
- * @param x X component of the translation value.
435
- * @param y Y component of the translation value.
436
- * @param z Z component of the translation value.
437
- * @return this matrix (modified)
438
- */
439
- translateSelf(t, e, i) {
440
- return this.multiplySelf(v(t, e ?? 0, i ?? 0));
441
- }
442
- /**
443
- * Modifies the current matrix by post-multiplying it with a scale matrix.
444
- * This is the mutable version of scale().
445
- *
446
- * @param x The X component of the scale value.
447
- * @param y The Y component of the scale value.
448
- * @param z The Z component of the scale value.
449
- * @return this matrix (modified)
450
- */
451
- scaleSelf(t, e, i) {
452
- return this.multiplySelf(O(t, e ?? t, i ?? 1));
453
- }
454
- /**
455
- * Modifies the current matrix by post-multiplying it with a rotation matrix.
456
- * This is the mutable version of rotate().
457
- *
458
- * @param rx The X component of the rotation, or Z if Y and Z are null.
459
- * @param ry The (optional) Y component of the rotation value.
460
- * @param rz The (optional) Z component of the rotation value.
461
- * @return this matrix (modified)
462
- */
463
- rotateSelf(t, e, i) {
464
- let n = t, m = e || 0, a = i || 0;
465
- return typeof t == "number" && typeof e > "u" && typeof i > "u" && (a = n, n = 0, m = 0), this.multiplySelf(k(n, m, a));
466
- }
467
- /**
468
- * Modifies the current matrix by post-multiplying it with a rotation matrix
469
- * with the given axis and angle.
470
- * This is the mutable version of rotateAxisAngle().
471
- *
472
- * @param x The X component of the axis vector.
473
- * @param y The Y component of the axis vector.
474
- * @param z The Z component of the axis vector.
475
- * @param angle The angle of rotation about the axis vector, in degrees.
476
- * @return this matrix (modified)
477
- */
478
- rotateAxisAngleSelf(t = 0, e = 0, i = 0, n = 0) {
479
- if ([t, e, i, n].some((a) => !Number.isFinite(a)))
480
- throw new TypeError("CSSMatrix: expecting 4 values");
481
- return Math.sqrt(t * t + e * e + i * i) === 0 ? this : this.multiplySelf(X(t, e, i, n));
482
- }
483
- /**
484
- * Modifies the current matrix by post-multiplying it with a skewX matrix.
485
- * This is the mutable version of skewX().
486
- *
487
- * @param angle The angle amount in degrees to skew.
488
- * @return this matrix (modified)
489
- */
490
- skewXSelf(t) {
491
- return this.multiplySelf(Y(t));
492
- }
493
- /**
494
- * Modifies the current matrix by post-multiplying it with a skewY matrix.
495
- * This is the mutable version of skewY().
496
- *
497
- * @param angle The angle amount in degrees to skew.
498
- * @return this matrix (modified)
499
- */
500
- skewYSelf(t) {
501
- return this.multiplySelf(F(t));
502
- }
503
- /**
504
- * Modifies the current matrix by post-multiplying it with a skew matrix.
505
- * This is the mutable version of skew().
506
- *
507
- * @param angleX The X-angle amount in degrees to skew.
508
- * @param angleY The Y-angle amount in degrees to skew.
509
- * @return this matrix (modified)
510
- */
511
- skewSelf(t, e) {
512
- return this.multiplySelf(A(t, e));
513
- }
514
- /**
515
- * Transforms a specified vector using the matrix, returning a new
516
- * {x,y,z,w} Tuple *Object* comprising the transformed vector.
517
- * Neither the matrix nor the original vector are altered.
518
- *
519
- * The method is equivalent with `transformPoint()` method
520
- * of the `DOMMatrix` constructor.
521
- *
522
- * @param t Tuple with `{x,y,z,w}` components
523
- * @return the resulting Tuple
524
- */
525
- transformPoint(t) {
526
- 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;
527
- return t instanceof DOMPoint ? new DOMPoint(e, i, n, m) : {
528
- x: e,
529
- y: i,
530
- z: n,
531
- w: m
532
- };
533
- }
534
- }
535
- export {
536
- M as default
537
- };
538
- //# sourceMappingURL=dommatrix.mjs.map
302
+ //#endregion
303
+ export { h as default };
304
+
305
+ //# sourceMappingURL=dommatrix.mjs.map