@thednp/dommatrix 2.0.12 → 3.0.0
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 -5
- package/dist/dommatrix.cjs +1 -2
- package/dist/dommatrix.cjs.map +1 -1
- package/dist/dommatrix.d.ts +75 -0
- package/dist/dommatrix.js +1 -2
- package/dist/dommatrix.js.map +1 -1
- package/dist/dommatrix.mjs +226 -120
- package/dist/dommatrix.mjs.map +1 -1
- package/package.json +12 -10
- package/vite.config.ts +38 -0
- package/vitest.config.ts +21 -0
package/dist/dommatrix.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var z = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
-
var p = (s, t, e) => z(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
const $ = {
|
|
1
|
+
const I = {
|
|
5
2
|
a: 1,
|
|
6
3
|
b: 0,
|
|
7
4
|
c: 0,
|
|
@@ -26,41 +23,40 @@ const $ = {
|
|
|
26
23
|
m44: 1,
|
|
27
24
|
is2D: !0,
|
|
28
25
|
isIdentity: !0
|
|
29
|
-
},
|
|
30
|
-
const t = new
|
|
31
|
-
if (!
|
|
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))
|
|
32
29
|
throw TypeError(
|
|
33
30
|
`CSSMatrix: "${e.join(",")}" must be an array with 6/16 numbers.`
|
|
34
31
|
);
|
|
35
|
-
// istanbul ignore else @preserve
|
|
36
32
|
if (e.length === 16) {
|
|
37
33
|
const [
|
|
38
|
-
n,
|
|
39
34
|
i,
|
|
35
|
+
n,
|
|
40
36
|
r,
|
|
41
37
|
a,
|
|
42
|
-
l,
|
|
43
|
-
m,
|
|
44
38
|
h,
|
|
39
|
+
m,
|
|
40
|
+
l,
|
|
45
41
|
c,
|
|
46
42
|
u,
|
|
47
43
|
f,
|
|
48
|
-
|
|
44
|
+
p,
|
|
49
45
|
o,
|
|
46
|
+
y,
|
|
50
47
|
d,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
b
|
|
48
|
+
S,
|
|
49
|
+
A
|
|
54
50
|
] = e;
|
|
55
|
-
t.m11 =
|
|
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;
|
|
56
52
|
} else if (e.length === 6) {
|
|
57
|
-
const [
|
|
58
|
-
t.m11 =
|
|
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;
|
|
59
55
|
}
|
|
60
56
|
return t;
|
|
61
|
-
},
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
57
|
+
}, C = (s) => {
|
|
58
|
+
if (E(s))
|
|
59
|
+
return x([
|
|
64
60
|
s.m11,
|
|
65
61
|
s.m12,
|
|
66
62
|
s.m13,
|
|
@@ -79,61 +75,63 @@ const $ = {
|
|
|
79
75
|
s.m44
|
|
80
76
|
]);
|
|
81
77
|
throw TypeError(
|
|
82
|
-
`CSSMatrix: "${JSON.stringify(
|
|
78
|
+
`CSSMatrix: "${JSON.stringify(
|
|
79
|
+
s
|
|
80
|
+
)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`
|
|
83
81
|
);
|
|
84
|
-
},
|
|
82
|
+
}, R = (s) => {
|
|
85
83
|
if (typeof s != "string")
|
|
86
84
|
throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a string.`);
|
|
87
85
|
const t = String(s).replace(/\s/g, "");
|
|
88
|
-
let e = new
|
|
89
|
-
const
|
|
90
|
-
return t.split(")").filter((
|
|
91
|
-
const [r, a] =
|
|
92
|
-
if (!a) throw TypeError(
|
|
93
|
-
const
|
|
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(
|
|
94
92
|
(o) => o.includes("rad") ? parseFloat(o) * (180 / Math.PI) : parseFloat(o)
|
|
95
|
-
), [m,
|
|
96
|
-
if (r === "perspective" && m && [
|
|
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))
|
|
97
95
|
e.m34 = -1 / m;
|
|
98
|
-
else if (r.includes("matrix") && [6, 16].includes(
|
|
99
|
-
const o =
|
|
100
|
-
e = e.multiply(
|
|
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));
|
|
101
99
|
} else if (r === "translate3d" && f.every((o) => !Number.isNaN(+o)))
|
|
102
|
-
e = e.translate(m,
|
|
100
|
+
e = e.translate(m, l, c);
|
|
103
101
|
else if (r === "translate" && m && c === void 0)
|
|
104
|
-
e = e.translate(m,
|
|
105
|
-
else if (r === "rotate3d" &&
|
|
106
|
-
e = e.rotateAxisAngle(m,
|
|
107
|
-
else if (r === "rotate" && m && [
|
|
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))
|
|
108
106
|
e = e.rotate(0, 0, m);
|
|
109
107
|
else if (r === "scale3d" && f.every((o) => !Number.isNaN(+o)) && f.some((o) => o !== 1))
|
|
110
|
-
e = e.scale(m,
|
|
108
|
+
e = e.scale(m, l, c);
|
|
111
109
|
else if (
|
|
112
110
|
// prop === "scale" && !Number.isNaN(x) && x !== 1 && z === undefined
|
|
113
111
|
// prop === "scale" && !Number.isNaN(x) && [x, y].some((n) => n !== 1) &&
|
|
114
|
-
r === "scale" && !Number.isNaN(m) && (m !== 1 ||
|
|
112
|
+
r === "scale" && !Number.isNaN(m) && (m !== 1 || l !== 1) && c === void 0
|
|
115
113
|
) {
|
|
116
|
-
const
|
|
117
|
-
e = e.scale(m,
|
|
118
|
-
} else if (r === "skew" && (m || !Number.isNaN(m) &&
|
|
119
|
-
e = e.skew(m,
|
|
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);
|
|
120
118
|
else if (["translate", "rotate", "scale", "skew"].some(
|
|
121
119
|
(o) => r.includes(o)
|
|
122
|
-
) && /[XYZ]/.test(r) && m && [
|
|
120
|
+
) && /[XYZ]/.test(r) && m && [l, c].every((o) => o === void 0))
|
|
123
121
|
if (r === "skewX" || r === "skewY")
|
|
124
122
|
e = e[r](m);
|
|
125
123
|
else {
|
|
126
|
-
const o = r.replace(/[XYZ]/, ""),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
130
128
|
];
|
|
131
|
-
e = e[o](...
|
|
129
|
+
e = e[o](...A);
|
|
132
130
|
}
|
|
133
131
|
else
|
|
134
|
-
throw TypeError(
|
|
132
|
+
throw TypeError(i);
|
|
135
133
|
}), e;
|
|
136
|
-
},
|
|
134
|
+
}, N = (s, t) => t ? [s.a, s.b, s.c, s.d, s.e, s.f] : [
|
|
137
135
|
s.m11,
|
|
138
136
|
s.m12,
|
|
139
137
|
s.m13,
|
|
@@ -150,64 +148,78 @@ const $ = {
|
|
|
150
148
|
s.m42,
|
|
151
149
|
s.m43,
|
|
152
150
|
s.m44
|
|
153
|
-
],
|
|
154
|
-
const
|
|
155
|
-
return
|
|
156
|
-
},
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
return
|
|
163
|
-
},
|
|
164
|
-
const
|
|
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);
|
|
165
163
|
if (r === 0)
|
|
166
|
-
return
|
|
167
|
-
const a = s / r,
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
return
|
|
175
|
-
},
|
|
176
|
-
const
|
|
177
|
-
return
|
|
178
|
-
},
|
|
179
|
-
const e = new
|
|
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();
|
|
180
178
|
if (s) {
|
|
181
|
-
const
|
|
182
|
-
e.m21 =
|
|
179
|
+
const i = s * Math.PI / 180, n = Math.tan(i);
|
|
180
|
+
e.m21 = n, e.c = n;
|
|
183
181
|
}
|
|
184
182
|
if (t) {
|
|
185
|
-
const
|
|
186
|
-
e.m12 =
|
|
183
|
+
const i = t * Math.PI / 180, n = Math.tan(i);
|
|
184
|
+
e.m12 = n, e.b = n;
|
|
187
185
|
}
|
|
188
186
|
return e;
|
|
189
|
-
},
|
|
190
|
-
const e = t.m11 * s.m11 + t.m12 * s.m21 + t.m13 * s.m31 + t.m14 * s.m41,
|
|
191
|
-
return
|
|
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([
|
|
192
190
|
e,
|
|
193
|
-
n,
|
|
194
191
|
i,
|
|
192
|
+
n,
|
|
195
193
|
r,
|
|
196
194
|
a,
|
|
197
|
-
l,
|
|
198
|
-
m,
|
|
199
195
|
h,
|
|
196
|
+
m,
|
|
197
|
+
l,
|
|
200
198
|
c,
|
|
201
199
|
u,
|
|
202
200
|
f,
|
|
203
|
-
|
|
201
|
+
p,
|
|
204
202
|
o,
|
|
203
|
+
y,
|
|
205
204
|
d,
|
|
206
|
-
|
|
207
|
-
M
|
|
205
|
+
S
|
|
208
206
|
]);
|
|
209
207
|
};
|
|
210
|
-
class
|
|
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;
|
|
211
223
|
/**
|
|
212
224
|
* @constructor
|
|
213
225
|
* @param init accepts all parameter configurations:
|
|
@@ -252,7 +264,7 @@ class y {
|
|
|
252
264
|
* @return the matrix instance
|
|
253
265
|
*/
|
|
254
266
|
setMatrixValue(t) {
|
|
255
|
-
return typeof t == "string" && t.length && t !== "none" ?
|
|
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;
|
|
256
268
|
}
|
|
257
269
|
/**
|
|
258
270
|
* Returns a *Float32Array* containing elements which comprise the matrix.
|
|
@@ -263,7 +275,7 @@ class y {
|
|
|
263
275
|
* @return an *Array* representation of the matrix
|
|
264
276
|
*/
|
|
265
277
|
toFloat32Array(t) {
|
|
266
|
-
return Float32Array.from(
|
|
278
|
+
return Float32Array.from(N(this, t));
|
|
267
279
|
}
|
|
268
280
|
/**
|
|
269
281
|
* Returns a *Float64Array* containing elements which comprise the matrix.
|
|
@@ -274,7 +286,7 @@ class y {
|
|
|
274
286
|
* @return an *Array* representation of the matrix
|
|
275
287
|
*/
|
|
276
288
|
toFloat64Array(t) {
|
|
277
|
-
return Float64Array.from(
|
|
289
|
+
return Float64Array.from(N(this, t));
|
|
278
290
|
}
|
|
279
291
|
/**
|
|
280
292
|
* Creates and returns a string representation of the matrix in `CSS` matrix syntax,
|
|
@@ -312,7 +324,7 @@ class y {
|
|
|
312
324
|
* @return The resulted matrix.
|
|
313
325
|
*/
|
|
314
326
|
multiply(t) {
|
|
315
|
-
return
|
|
327
|
+
return M(this, t);
|
|
316
328
|
}
|
|
317
329
|
/**
|
|
318
330
|
* The translate method returns a new matrix which is this matrix post
|
|
@@ -325,10 +337,10 @@ class y {
|
|
|
325
337
|
* @param z Z component of the translation value.
|
|
326
338
|
* @return The resulted matrix
|
|
327
339
|
*/
|
|
328
|
-
translate(t, e,
|
|
329
|
-
const
|
|
330
|
-
let r = e, a =
|
|
331
|
-
return typeof r > "u" && (r = 0), typeof a > "u" && (a = 0),
|
|
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));
|
|
332
344
|
}
|
|
333
345
|
/**
|
|
334
346
|
* The scale method returns a new matrix which is this matrix post multiplied by
|
|
@@ -341,10 +353,10 @@ class y {
|
|
|
341
353
|
* @param z The Z component of the scale value.
|
|
342
354
|
* @return The resulted matrix
|
|
343
355
|
*/
|
|
344
|
-
scale(t, e,
|
|
345
|
-
const
|
|
346
|
-
let r = e, a =
|
|
347
|
-
return typeof r > "u" && (r = t), typeof a > "u" && (a = 1),
|
|
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));
|
|
348
360
|
}
|
|
349
361
|
/**
|
|
350
362
|
* The rotate method returns a new matrix which is this matrix post multiplied
|
|
@@ -358,9 +370,9 @@ class y {
|
|
|
358
370
|
* @param rz The (optional) Z component of the rotation value.
|
|
359
371
|
* @return The resulted matrix
|
|
360
372
|
*/
|
|
361
|
-
rotate(t, e,
|
|
362
|
-
let
|
|
363
|
-
return typeof t == "number" && typeof e > "u" && typeof
|
|
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));
|
|
364
376
|
}
|
|
365
377
|
/**
|
|
366
378
|
* The rotateAxisAngle method returns a new matrix which is this matrix post
|
|
@@ -374,10 +386,10 @@ class y {
|
|
|
374
386
|
* @param angle The angle of rotation about the axis vector, in degrees.
|
|
375
387
|
* @return The resulted matrix
|
|
376
388
|
*/
|
|
377
|
-
rotateAxisAngle(t, e,
|
|
378
|
-
if ([t, e,
|
|
389
|
+
rotateAxisAngle(t, e, i, n) {
|
|
390
|
+
if ([t, e, i, n].some((r) => !Number.isFinite(r)))
|
|
379
391
|
throw new TypeError("CSSMatrix: expecting 4 values");
|
|
380
|
-
return
|
|
392
|
+
return M(this, k(t, e, i, n));
|
|
381
393
|
}
|
|
382
394
|
/**
|
|
383
395
|
* Specifies a skew transformation along the `x-axis` by the given angle.
|
|
@@ -387,7 +399,7 @@ class y {
|
|
|
387
399
|
* @return The resulted matrix
|
|
388
400
|
*/
|
|
389
401
|
skewX(t) {
|
|
390
|
-
return
|
|
402
|
+
return M(this, Y(t));
|
|
391
403
|
}
|
|
392
404
|
/**
|
|
393
405
|
* Specifies a skew transformation along the `y-axis` by the given angle.
|
|
@@ -397,7 +409,7 @@ class y {
|
|
|
397
409
|
* @return The resulted matrix
|
|
398
410
|
*/
|
|
399
411
|
skewY(t) {
|
|
400
|
-
return
|
|
412
|
+
return M(this, O(t));
|
|
401
413
|
}
|
|
402
414
|
/**
|
|
403
415
|
* Specifies a skew transformation along both the `x-axis` and `y-axis`.
|
|
@@ -408,7 +420,102 @@ class y {
|
|
|
408
420
|
* @return The resulted matrix
|
|
409
421
|
*/
|
|
410
422
|
skew(t, e) {
|
|
411
|
-
return
|
|
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));
|
|
412
519
|
}
|
|
413
520
|
/**
|
|
414
521
|
* Transforms a specified vector using the matrix, returning a new
|
|
@@ -422,17 +529,16 @@ class y {
|
|
|
422
529
|
* @return the resulting Tuple
|
|
423
530
|
*/
|
|
424
531
|
transformPoint(t) {
|
|
425
|
-
const e = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w,
|
|
426
|
-
return t instanceof DOMPoint ? new DOMPoint(e,
|
|
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) : {
|
|
427
534
|
x: e,
|
|
428
|
-
y:
|
|
429
|
-
z:
|
|
535
|
+
y: i,
|
|
536
|
+
z: n,
|
|
430
537
|
w: r
|
|
431
538
|
};
|
|
432
539
|
}
|
|
433
540
|
}
|
|
434
|
-
p(y, "Translate", Y), p(y, "Rotate", F), p(y, "RotateAxisAngle", T), p(y, "Scale", I), p(y, "SkewX", R), p(y, "SkewY", D), p(y, "Skew", v), p(y, "Multiply", N), p(y, "fromArray", g), p(y, "fromMatrix", X), p(y, "fromString", O), p(y, "toArray", x), p(y, "isCompatibleArray", E), p(y, "isCompatibleObject", P);
|
|
435
541
|
export {
|
|
436
|
-
|
|
542
|
+
w as default
|
|
437
543
|
};
|
|
438
544
|
//# sourceMappingURL=dommatrix.mjs.map
|