@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.
- package/README.md +4 -3
- package/dist/dommatrix.cjs +2 -2
- package/dist/dommatrix.cjs.map +1 -1
- package/dist/dommatrix.d.ts +3 -3
- package/dist/dommatrix.js +2 -2
- package/dist/dommatrix.js.map +1 -1
- package/dist/dommatrix.mjs +304 -543
- package/dist/dommatrix.mjs.map +1 -1
- package/package.json +9 -9
package/dist/dommatrix.mjs
CHANGED
|
@@ -1,544 +1,305 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|