@zag-js/rect-utils 1.46.0 → 1.48.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/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
- package/dist/affine-transform.d.mts +36 -39
- package/dist/affine-transform.d.ts +36 -39
- package/dist/affine-transform.js +189 -187
- package/dist/affine-transform.mjs +185 -164
- package/dist/align.d.mts +2 -5
- package/dist/align.d.ts +2 -5
- package/dist/align.js +27 -44
- package/dist/align.mjs +23 -21
- package/dist/angle.d.mts +2 -5
- package/dist/angle.d.ts +2 -5
- package/dist/angle.js +8 -32
- package/dist/angle.mjs +4 -9
- package/dist/clamp.d.mts +8 -11
- package/dist/clamp.d.ts +8 -11
- package/dist/clamp.js +23 -46
- package/dist/clamp.mjs +18 -22
- package/dist/closest.d.mts +4 -7
- package/dist/closest.d.ts +4 -7
- package/dist/closest.js +35 -62
- package/dist/closest.mjs +29 -37
- package/dist/compass.d.mts +4 -7
- package/dist/compass.d.ts +4 -7
- package/dist/compass.js +48 -48
- package/dist/compass.mjs +43 -24
- package/dist/constrain.d.mts +2 -5
- package/dist/constrain.d.ts +2 -5
- package/dist/constrain.js +12 -37
- package/dist/constrain.mjs +8 -14
- package/dist/contains.d.mts +4 -7
- package/dist/contains.d.ts +4 -7
- package/dist/contains.js +11 -36
- package/dist/contains.mjs +5 -11
- package/dist/distance.d.mts +7 -10
- package/dist/distance.d.ts +7 -10
- package/dist/distance.js +55 -60
- package/dist/distance.mjs +48 -34
- package/dist/equality.d.mts +4 -7
- package/dist/equality.d.ts +4 -7
- package/dist/equality.js +13 -38
- package/dist/equality.mjs +7 -13
- package/dist/from-element.d.mts +12 -15
- package/dist/from-element.d.ts +12 -15
- package/dist/from-element.js +39 -58
- package/dist/from-element.mjs +35 -35
- package/dist/from-points.d.mts +2 -5
- package/dist/from-points.d.ts +2 -5
- package/dist/from-points.js +18 -36
- package/dist/from-points.mjs +14 -13
- package/dist/from-range.d.mts +2 -5
- package/dist/from-range.d.ts +2 -5
- package/dist/from-range.js +25 -46
- package/dist/from-range.mjs +19 -21
- package/dist/from-rotation.d.mts +4 -7
- package/dist/from-rotation.d.ts +4 -7
- package/dist/from-rotation.js +31 -56
- package/dist/from-rotation.mjs +25 -31
- package/dist/from-window.d.mts +13 -16
- package/dist/from-window.d.ts +13 -16
- package/dist/from-window.js +29 -44
- package/dist/from-window.mjs +24 -20
- package/dist/index.d.mts +22 -22
- package/dist/index.d.ts +22 -22
- package/dist/index.js +72 -63
- package/dist/index.mjs +21 -22
- package/dist/intersection.d.mts +4 -7
- package/dist/intersection.d.ts +4 -7
- package/dist/intersection.js +34 -45
- package/dist/intersection.mjs +28 -20
- package/dist/operations.d.mts +6 -9
- package/dist/operations.d.ts +6 -9
- package/dist/operations.js +38 -57
- package/dist/operations.mjs +30 -30
- package/dist/polygon.d.mts +6 -9
- package/dist/polygon.d.ts +6 -9
- package/dist/polygon.js +73 -82
- package/dist/polygon.mjs +67 -57
- package/dist/rect.d.mts +49 -52
- package/dist/rect.d.ts +49 -52
- package/dist/rect.js +57 -82
- package/dist/rect.mjs +46 -52
- package/dist/resize.d.mts +3 -6
- package/dist/resize.d.ts +3 -6
- package/dist/resize.js +73 -102
- package/dist/resize.mjs +68 -78
- package/dist/types.d.mts +45 -49
- package/dist/types.d.ts +45 -49
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/dist/union.d.mts +2 -5
- package/dist/union.d.ts +2 -5
- package/dist/union.js +16 -39
- package/dist/union.mjs +12 -16
- package/package.json +3 -3
- package/dist/chunk-QZ7TP4HQ.mjs +0 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_toPropertyKey = require("./toPropertyKey.js");
|
|
2
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = require_toPropertyKey.default(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
exports.default = _defineProperty;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import toPropertyKey from "./toPropertyKey.mjs";
|
|
2
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
export { _defineProperty as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_typeof = require("./typeof.js");
|
|
2
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, e) {
|
|
4
|
+
if ("object" != require_typeof.default(t) || !t) return t;
|
|
5
|
+
var r;
|
|
6
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
7
|
+
var i = r.call(t, e || "default");
|
|
8
|
+
if ("object" != require_typeof.default(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === e ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
exports.default = toPrimitive;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _typeof from "./typeof.mjs";
|
|
2
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, e) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var r;
|
|
6
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
7
|
+
var i = r.call(t, e || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === e ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
export { toPrimitive as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_typeof = require("./typeof.js");
|
|
2
|
+
const require_toPrimitive = require("./toPrimitive.js");
|
|
3
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = require_toPrimitive.default(t, "string");
|
|
6
|
+
return "symbol" == require_typeof.default(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
exports.default = toPropertyKey;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _typeof from "./typeof.mjs";
|
|
2
|
+
import toPrimitive from "./toPrimitive.mjs";
|
|
3
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
export { toPropertyKey as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(exports, "default", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return _typeof;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
export { _typeof as default };
|
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
import { Point } from
|
|
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
|
-
export { AffineTransform };
|
|
1
|
+
import { Point } from "./types.mjs";
|
|
2
|
+
export declare class AffineTransform {
|
|
3
|
+
m00: number;
|
|
4
|
+
m01: number;
|
|
5
|
+
m02: number;
|
|
6
|
+
m10: number;
|
|
7
|
+
m11: number;
|
|
8
|
+
m12: number;
|
|
9
|
+
constructor([m00, m01, m02, m10, m11, m12]?: Iterable<number>);
|
|
10
|
+
applyTo(point: Point): Point;
|
|
11
|
+
prepend(other: AffineTransform): AffineTransform;
|
|
12
|
+
append(other: AffineTransform): AffineTransform;
|
|
13
|
+
get determinant(): number;
|
|
14
|
+
get isInvertible(): boolean;
|
|
15
|
+
invert(): AffineTransform;
|
|
16
|
+
get array(): number[];
|
|
17
|
+
get float32Array(): Float32Array;
|
|
18
|
+
static get identity(): AffineTransform;
|
|
19
|
+
static rotate(theta: number, origin?: Point): AffineTransform;
|
|
20
|
+
rotate: (typeof AffineTransform)["rotate"];
|
|
21
|
+
static scale(sx: number, sy?: number, origin?: Point): AffineTransform;
|
|
22
|
+
scale: (typeof AffineTransform)["scale"];
|
|
23
|
+
static translate(tx: number, ty: number): AffineTransform;
|
|
24
|
+
translate: (typeof AffineTransform)["translate"];
|
|
25
|
+
static multiply(...[first, ...rest]: AffineTransform[]): AffineTransform;
|
|
26
|
+
get a(): number;
|
|
27
|
+
get b(): number;
|
|
28
|
+
get c(): number;
|
|
29
|
+
get d(): number;
|
|
30
|
+
get tx(): number;
|
|
31
|
+
get ty(): number;
|
|
32
|
+
get scaleComponents(): Point;
|
|
33
|
+
get translationComponents(): Point;
|
|
34
|
+
get skewComponents(): Point;
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
import { Point } from
|
|
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
|
-
export { AffineTransform };
|
|
1
|
+
import { Point } from "./types.js";
|
|
2
|
+
export declare class AffineTransform {
|
|
3
|
+
m00: number;
|
|
4
|
+
m01: number;
|
|
5
|
+
m02: number;
|
|
6
|
+
m10: number;
|
|
7
|
+
m11: number;
|
|
8
|
+
m12: number;
|
|
9
|
+
constructor([m00, m01, m02, m10, m11, m12]?: Iterable<number>);
|
|
10
|
+
applyTo(point: Point): Point;
|
|
11
|
+
prepend(other: AffineTransform): AffineTransform;
|
|
12
|
+
append(other: AffineTransform): AffineTransform;
|
|
13
|
+
get determinant(): number;
|
|
14
|
+
get isInvertible(): boolean;
|
|
15
|
+
invert(): AffineTransform;
|
|
16
|
+
get array(): number[];
|
|
17
|
+
get float32Array(): Float32Array;
|
|
18
|
+
static get identity(): AffineTransform;
|
|
19
|
+
static rotate(theta: number, origin?: Point): AffineTransform;
|
|
20
|
+
rotate: (typeof AffineTransform)["rotate"];
|
|
21
|
+
static scale(sx: number, sy?: number, origin?: Point): AffineTransform;
|
|
22
|
+
scale: (typeof AffineTransform)["scale"];
|
|
23
|
+
static translate(tx: number, ty: number): AffineTransform;
|
|
24
|
+
translate: (typeof AffineTransform)["translate"];
|
|
25
|
+
static multiply(...[first, ...rest]: AffineTransform[]): AffineTransform;
|
|
26
|
+
get a(): number;
|
|
27
|
+
get b(): number;
|
|
28
|
+
get c(): number;
|
|
29
|
+
get d(): number;
|
|
30
|
+
get tx(): number;
|
|
31
|
+
get ty(): number;
|
|
32
|
+
get scaleComponents(): Point;
|
|
33
|
+
get translationComponents(): Point;
|
|
34
|
+
get skewComponents(): Point;
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
package/dist/affine-transform.js
CHANGED
|
@@ -1,189 +1,191 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
|
|
22
|
-
// src/affine-transform.ts
|
|
23
|
-
var affine_transform_exports = {};
|
|
24
|
-
__export(affine_transform_exports, {
|
|
25
|
-
AffineTransform: () => AffineTransform
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
26
4
|
});
|
|
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
|
-
|
|
5
|
+
const require_defineProperty = require("./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js");
|
|
6
|
+
// src/affine-transform.ts
|
|
7
|
+
var AffineTransform = class AffineTransform {
|
|
8
|
+
constructor([m00, m01, m02, m10, m11, m12] = [
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
0,
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
0
|
|
15
|
+
]) {
|
|
16
|
+
require_defineProperty.default(this, "m00", void 0);
|
|
17
|
+
require_defineProperty.default(this, "m01", void 0);
|
|
18
|
+
require_defineProperty.default(this, "m02", void 0);
|
|
19
|
+
require_defineProperty.default(this, "m10", void 0);
|
|
20
|
+
require_defineProperty.default(this, "m11", void 0);
|
|
21
|
+
require_defineProperty.default(this, "m12", void 0);
|
|
22
|
+
require_defineProperty.default(this, "rotate", (...args) => {
|
|
23
|
+
return this.prepend(AffineTransform.rotate(...args));
|
|
24
|
+
});
|
|
25
|
+
require_defineProperty.default(this, "scale", (...args) => {
|
|
26
|
+
return this.prepend(AffineTransform.scale(...args));
|
|
27
|
+
});
|
|
28
|
+
require_defineProperty.default(this, "translate", (...args) => {
|
|
29
|
+
return this.prepend(AffineTransform.translate(...args));
|
|
30
|
+
});
|
|
31
|
+
this.m00 = m00;
|
|
32
|
+
this.m01 = m01;
|
|
33
|
+
this.m02 = m02;
|
|
34
|
+
this.m10 = m10;
|
|
35
|
+
this.m11 = m11;
|
|
36
|
+
this.m12 = m12;
|
|
37
|
+
}
|
|
38
|
+
applyTo(point) {
|
|
39
|
+
const { x, y } = point;
|
|
40
|
+
const { m00, m01, m02, m10, m11, m12 } = this;
|
|
41
|
+
return {
|
|
42
|
+
x: m00 * x + m01 * y + m02,
|
|
43
|
+
y: m10 * x + m11 * y + m12
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
prepend(other) {
|
|
47
|
+
return new AffineTransform([
|
|
48
|
+
this.m00 * other.m00 + this.m01 * other.m10,
|
|
49
|
+
this.m00 * other.m01 + this.m01 * other.m11,
|
|
50
|
+
this.m00 * other.m02 + this.m01 * other.m12 + this.m02,
|
|
51
|
+
this.m10 * other.m00 + this.m11 * other.m10,
|
|
52
|
+
this.m10 * other.m01 + this.m11 * other.m11,
|
|
53
|
+
this.m10 * other.m02 + this.m11 * other.m12 + this.m12
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
append(other) {
|
|
57
|
+
return new AffineTransform([
|
|
58
|
+
other.m00 * this.m00 + other.m01 * this.m10,
|
|
59
|
+
other.m00 * this.m01 + other.m01 * this.m11,
|
|
60
|
+
other.m00 * this.m02 + other.m01 * this.m12 + other.m02,
|
|
61
|
+
other.m10 * this.m00 + other.m11 * this.m10,
|
|
62
|
+
other.m10 * this.m01 + other.m11 * this.m11,
|
|
63
|
+
other.m10 * this.m02 + other.m11 * this.m12 + other.m12
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
get determinant() {
|
|
67
|
+
return this.m00 * this.m11 - this.m01 * this.m10;
|
|
68
|
+
}
|
|
69
|
+
get isInvertible() {
|
|
70
|
+
const det = this.determinant;
|
|
71
|
+
return isFinite(det) && isFinite(this.m02) && isFinite(this.m12) && det !== 0;
|
|
72
|
+
}
|
|
73
|
+
invert() {
|
|
74
|
+
const det = this.determinant;
|
|
75
|
+
return new AffineTransform([
|
|
76
|
+
this.m11 / det,
|
|
77
|
+
-this.m01 / det,
|
|
78
|
+
(this.m01 * this.m12 - this.m11 * this.m02) / det,
|
|
79
|
+
-this.m10 / det,
|
|
80
|
+
this.m00 / det,
|
|
81
|
+
(this.m10 * this.m02 - this.m00 * this.m12) / det
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
get array() {
|
|
85
|
+
return [
|
|
86
|
+
this.m00,
|
|
87
|
+
this.m01,
|
|
88
|
+
this.m02,
|
|
89
|
+
this.m10,
|
|
90
|
+
this.m11,
|
|
91
|
+
this.m12,
|
|
92
|
+
0,
|
|
93
|
+
0,
|
|
94
|
+
1
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
get float32Array() {
|
|
98
|
+
return new Float32Array(this.array);
|
|
99
|
+
}
|
|
100
|
+
static get identity() {
|
|
101
|
+
return new AffineTransform([
|
|
102
|
+
1,
|
|
103
|
+
0,
|
|
104
|
+
0,
|
|
105
|
+
0,
|
|
106
|
+
1,
|
|
107
|
+
0
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
static rotate(theta, origin) {
|
|
111
|
+
const rotation = new AffineTransform([
|
|
112
|
+
Math.cos(theta),
|
|
113
|
+
-Math.sin(theta),
|
|
114
|
+
0,
|
|
115
|
+
Math.sin(theta),
|
|
116
|
+
Math.cos(theta),
|
|
117
|
+
0
|
|
118
|
+
]);
|
|
119
|
+
if (origin && (origin.x !== 0 || origin.y !== 0)) return AffineTransform.multiply(AffineTransform.translate(origin.x, origin.y), rotation, AffineTransform.translate(-origin.x, -origin.y));
|
|
120
|
+
return rotation;
|
|
121
|
+
}
|
|
122
|
+
static scale(sx, sy = sx, origin = {
|
|
123
|
+
x: 0,
|
|
124
|
+
y: 0
|
|
125
|
+
}) {
|
|
126
|
+
const scale = new AffineTransform([
|
|
127
|
+
sx,
|
|
128
|
+
0,
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
sy,
|
|
132
|
+
0
|
|
133
|
+
]);
|
|
134
|
+
if (origin.x !== 0 || origin.y !== 0) return AffineTransform.multiply(AffineTransform.translate(origin.x, origin.y), scale, AffineTransform.translate(-origin.x, -origin.y));
|
|
135
|
+
return scale;
|
|
136
|
+
}
|
|
137
|
+
static translate(tx, ty) {
|
|
138
|
+
return new AffineTransform([
|
|
139
|
+
1,
|
|
140
|
+
0,
|
|
141
|
+
tx,
|
|
142
|
+
0,
|
|
143
|
+
1,
|
|
144
|
+
ty
|
|
145
|
+
]);
|
|
146
|
+
}
|
|
147
|
+
static multiply(...[first, ...rest]) {
|
|
148
|
+
if (!first) return AffineTransform.identity;
|
|
149
|
+
return rest.reduce((result, item) => result.prepend(item), first);
|
|
150
|
+
}
|
|
151
|
+
get a() {
|
|
152
|
+
return this.m00;
|
|
153
|
+
}
|
|
154
|
+
get b() {
|
|
155
|
+
return this.m10;
|
|
156
|
+
}
|
|
157
|
+
get c() {
|
|
158
|
+
return this.m01;
|
|
159
|
+
}
|
|
160
|
+
get d() {
|
|
161
|
+
return this.m11;
|
|
162
|
+
}
|
|
163
|
+
get tx() {
|
|
164
|
+
return this.m02;
|
|
165
|
+
}
|
|
166
|
+
get ty() {
|
|
167
|
+
return this.m12;
|
|
168
|
+
}
|
|
169
|
+
get scaleComponents() {
|
|
170
|
+
return {
|
|
171
|
+
x: this.a,
|
|
172
|
+
y: this.d
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
get translationComponents() {
|
|
176
|
+
return {
|
|
177
|
+
x: this.tx,
|
|
178
|
+
y: this.ty
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
get skewComponents() {
|
|
182
|
+
return {
|
|
183
|
+
x: this.c,
|
|
184
|
+
y: this.b
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
toString() {
|
|
188
|
+
return `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`;
|
|
189
|
+
}
|
|
185
190
|
};
|
|
186
|
-
|
|
187
|
-
0 && (module.exports = {
|
|
188
|
-
AffineTransform
|
|
189
|
-
});
|
|
191
|
+
exports.AffineTransform = AffineTransform;
|