@thednp/dommatrix 3.0.1 → 3.0.3

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