@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.
Files changed (102) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
  9. package/dist/affine-transform.d.mts +36 -39
  10. package/dist/affine-transform.d.ts +36 -39
  11. package/dist/affine-transform.js +189 -187
  12. package/dist/affine-transform.mjs +185 -164
  13. package/dist/align.d.mts +2 -5
  14. package/dist/align.d.ts +2 -5
  15. package/dist/align.js +27 -44
  16. package/dist/align.mjs +23 -21
  17. package/dist/angle.d.mts +2 -5
  18. package/dist/angle.d.ts +2 -5
  19. package/dist/angle.js +8 -32
  20. package/dist/angle.mjs +4 -9
  21. package/dist/clamp.d.mts +8 -11
  22. package/dist/clamp.d.ts +8 -11
  23. package/dist/clamp.js +23 -46
  24. package/dist/clamp.mjs +18 -22
  25. package/dist/closest.d.mts +4 -7
  26. package/dist/closest.d.ts +4 -7
  27. package/dist/closest.js +35 -62
  28. package/dist/closest.mjs +29 -37
  29. package/dist/compass.d.mts +4 -7
  30. package/dist/compass.d.ts +4 -7
  31. package/dist/compass.js +48 -48
  32. package/dist/compass.mjs +43 -24
  33. package/dist/constrain.d.mts +2 -5
  34. package/dist/constrain.d.ts +2 -5
  35. package/dist/constrain.js +12 -37
  36. package/dist/constrain.mjs +8 -14
  37. package/dist/contains.d.mts +4 -7
  38. package/dist/contains.d.ts +4 -7
  39. package/dist/contains.js +11 -36
  40. package/dist/contains.mjs +5 -11
  41. package/dist/distance.d.mts +7 -10
  42. package/dist/distance.d.ts +7 -10
  43. package/dist/distance.js +55 -60
  44. package/dist/distance.mjs +48 -34
  45. package/dist/equality.d.mts +4 -7
  46. package/dist/equality.d.ts +4 -7
  47. package/dist/equality.js +13 -38
  48. package/dist/equality.mjs +7 -13
  49. package/dist/from-element.d.mts +12 -15
  50. package/dist/from-element.d.ts +12 -15
  51. package/dist/from-element.js +39 -58
  52. package/dist/from-element.mjs +35 -35
  53. package/dist/from-points.d.mts +2 -5
  54. package/dist/from-points.d.ts +2 -5
  55. package/dist/from-points.js +18 -36
  56. package/dist/from-points.mjs +14 -13
  57. package/dist/from-range.d.mts +2 -5
  58. package/dist/from-range.d.ts +2 -5
  59. package/dist/from-range.js +25 -46
  60. package/dist/from-range.mjs +19 -21
  61. package/dist/from-rotation.d.mts +4 -7
  62. package/dist/from-rotation.d.ts +4 -7
  63. package/dist/from-rotation.js +31 -56
  64. package/dist/from-rotation.mjs +25 -31
  65. package/dist/from-window.d.mts +13 -16
  66. package/dist/from-window.d.ts +13 -16
  67. package/dist/from-window.js +29 -44
  68. package/dist/from-window.mjs +24 -20
  69. package/dist/index.d.mts +22 -22
  70. package/dist/index.d.ts +22 -22
  71. package/dist/index.js +72 -63
  72. package/dist/index.mjs +21 -22
  73. package/dist/intersection.d.mts +4 -7
  74. package/dist/intersection.d.ts +4 -7
  75. package/dist/intersection.js +34 -45
  76. package/dist/intersection.mjs +28 -20
  77. package/dist/operations.d.mts +6 -9
  78. package/dist/operations.d.ts +6 -9
  79. package/dist/operations.js +38 -57
  80. package/dist/operations.mjs +30 -30
  81. package/dist/polygon.d.mts +6 -9
  82. package/dist/polygon.d.ts +6 -9
  83. package/dist/polygon.js +73 -82
  84. package/dist/polygon.mjs +67 -57
  85. package/dist/rect.d.mts +49 -52
  86. package/dist/rect.d.ts +49 -52
  87. package/dist/rect.js +57 -82
  88. package/dist/rect.mjs +46 -52
  89. package/dist/resize.d.mts +3 -6
  90. package/dist/resize.d.ts +3 -6
  91. package/dist/resize.js +73 -102
  92. package/dist/resize.mjs +68 -78
  93. package/dist/types.d.mts +45 -49
  94. package/dist/types.d.ts +45 -49
  95. package/dist/types.js +4 -18
  96. package/dist/types.mjs +1 -0
  97. package/dist/union.d.mts +2 -5
  98. package/dist/union.d.ts +2 -5
  99. package/dist/union.js +16 -39
  100. package/dist/union.mjs +12 -16
  101. package/package.json +3 -3
  102. 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 './types.mjs';
2
-
3
- declare class AffineTransform {
4
- m00: number;
5
- m01: number;
6
- m02: number;
7
- m10: number;
8
- m11: number;
9
- m12: number;
10
- constructor([m00, m01, m02, m10, m11, m12]?: Iterable<number>);
11
- applyTo(point: Point): Point;
12
- prepend(other: AffineTransform): AffineTransform;
13
- append(other: AffineTransform): AffineTransform;
14
- get determinant(): number;
15
- get isInvertible(): boolean;
16
- invert(): AffineTransform;
17
- get array(): number[];
18
- get float32Array(): Float32Array;
19
- static get identity(): AffineTransform;
20
- static rotate(theta: number, origin?: Point): AffineTransform;
21
- rotate: (typeof AffineTransform)["rotate"];
22
- static scale(sx: number, sy?: number, origin?: Point): AffineTransform;
23
- scale: (typeof AffineTransform)["scale"];
24
- static translate(tx: number, ty: number): AffineTransform;
25
- translate: (typeof AffineTransform)["translate"];
26
- static multiply(...[first, ...rest]: AffineTransform[]): AffineTransform;
27
- get a(): number;
28
- get b(): number;
29
- get c(): number;
30
- get d(): number;
31
- get tx(): number;
32
- get ty(): number;
33
- get scaleComponents(): Point;
34
- get translationComponents(): Point;
35
- get skewComponents(): Point;
36
- toString(): string;
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 './types.js';
2
-
3
- declare class AffineTransform {
4
- m00: number;
5
- m01: number;
6
- m02: number;
7
- m10: number;
8
- m11: number;
9
- m12: number;
10
- constructor([m00, m01, m02, m10, m11, m12]?: Iterable<number>);
11
- applyTo(point: Point): Point;
12
- prepend(other: AffineTransform): AffineTransform;
13
- append(other: AffineTransform): AffineTransform;
14
- get determinant(): number;
15
- get isInvertible(): boolean;
16
- invert(): AffineTransform;
17
- get array(): number[];
18
- get float32Array(): Float32Array;
19
- static get identity(): AffineTransform;
20
- static rotate(theta: number, origin?: Point): AffineTransform;
21
- rotate: (typeof AffineTransform)["rotate"];
22
- static scale(sx: number, sy?: number, origin?: Point): AffineTransform;
23
- scale: (typeof AffineTransform)["scale"];
24
- static translate(tx: number, ty: number): AffineTransform;
25
- translate: (typeof AffineTransform)["translate"];
26
- static multiply(...[first, ...rest]: AffineTransform[]): AffineTransform;
27
- get a(): number;
28
- get b(): number;
29
- get c(): number;
30
- get d(): number;
31
- get tx(): number;
32
- get ty(): number;
33
- get scaleComponents(): Point;
34
- get translationComponents(): Point;
35
- get skewComponents(): Point;
36
- toString(): string;
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
+ }
@@ -1,189 +1,191 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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
- module.exports = __toCommonJS(affine_transform_exports);
28
- var AffineTransform = class _AffineTransform {
29
- constructor([m00, m01, m02, m10, m11, m12] = [0, 0, 0, 0, 0, 0]) {
30
- __publicField(this, "m00");
31
- __publicField(this, "m01");
32
- __publicField(this, "m02");
33
- __publicField(this, "m10");
34
- __publicField(this, "m11");
35
- __publicField(this, "m12");
36
- __publicField(this, "rotate", (...args) => {
37
- return this.prepend(_AffineTransform.rotate(...args));
38
- });
39
- __publicField(this, "scale", (...args) => {
40
- return this.prepend(_AffineTransform.scale(...args));
41
- });
42
- __publicField(this, "translate", (...args) => {
43
- return this.prepend(_AffineTransform.translate(...args));
44
- });
45
- this.m00 = m00;
46
- this.m01 = m01;
47
- this.m02 = m02;
48
- this.m10 = m10;
49
- this.m11 = m11;
50
- this.m12 = m12;
51
- }
52
- applyTo(point) {
53
- const { x, y } = point;
54
- const { m00, m01, m02, m10, m11, m12 } = this;
55
- return {
56
- x: m00 * x + m01 * y + m02,
57
- y: m10 * x + m11 * y + m12
58
- };
59
- }
60
- prepend(other) {
61
- return new _AffineTransform([
62
- this.m00 * other.m00 + this.m01 * other.m10,
63
- // m00
64
- this.m00 * other.m01 + this.m01 * other.m11,
65
- // m01
66
- this.m00 * other.m02 + this.m01 * other.m12 + this.m02,
67
- // m02
68
- this.m10 * other.m00 + this.m11 * other.m10,
69
- // m10
70
- this.m10 * other.m01 + this.m11 * other.m11,
71
- // m11
72
- this.m10 * other.m02 + this.m11 * other.m12 + this.m12
73
- // m12
74
- ]);
75
- }
76
- append(other) {
77
- return new _AffineTransform([
78
- other.m00 * this.m00 + other.m01 * this.m10,
79
- // m00
80
- other.m00 * this.m01 + other.m01 * this.m11,
81
- // m01
82
- other.m00 * this.m02 + other.m01 * this.m12 + other.m02,
83
- // m02
84
- other.m10 * this.m00 + other.m11 * this.m10,
85
- // m10
86
- other.m10 * this.m01 + other.m11 * this.m11,
87
- // m11
88
- other.m10 * this.m02 + other.m11 * this.m12 + other.m12
89
- // m12
90
- ]);
91
- }
92
- get determinant() {
93
- return this.m00 * this.m11 - this.m01 * this.m10;
94
- }
95
- get isInvertible() {
96
- const det = this.determinant;
97
- return isFinite(det) && isFinite(this.m02) && isFinite(this.m12) && det !== 0;
98
- }
99
- invert() {
100
- const det = this.determinant;
101
- return new _AffineTransform([
102
- this.m11 / det,
103
- // m00
104
- -this.m01 / det,
105
- // m01
106
- (this.m01 * this.m12 - this.m11 * this.m02) / det,
107
- // m02
108
- -this.m10 / det,
109
- // m10
110
- this.m00 / det,
111
- // m11
112
- (this.m10 * this.m02 - this.m00 * this.m12) / det
113
- // m12
114
- ]);
115
- }
116
- get array() {
117
- return [this.m00, this.m01, this.m02, this.m10, this.m11, this.m12, 0, 0, 1];
118
- }
119
- get float32Array() {
120
- return new Float32Array(this.array);
121
- }
122
- // Static
123
- static get identity() {
124
- return new _AffineTransform([1, 0, 0, 0, 1, 0]);
125
- }
126
- static rotate(theta, origin) {
127
- const rotation = new _AffineTransform([Math.cos(theta), -Math.sin(theta), 0, Math.sin(theta), Math.cos(theta), 0]);
128
- if (origin && (origin.x !== 0 || origin.y !== 0)) {
129
- return _AffineTransform.multiply(
130
- _AffineTransform.translate(origin.x, origin.y),
131
- rotation,
132
- _AffineTransform.translate(-origin.x, -origin.y)
133
- );
134
- }
135
- return rotation;
136
- }
137
- static scale(sx, sy = sx, origin = { x: 0, y: 0 }) {
138
- const scale = new _AffineTransform([sx, 0, 0, 0, sy, 0]);
139
- if (origin.x !== 0 || origin.y !== 0) {
140
- return _AffineTransform.multiply(
141
- _AffineTransform.translate(origin.x, origin.y),
142
- scale,
143
- _AffineTransform.translate(-origin.x, -origin.y)
144
- );
145
- }
146
- return scale;
147
- }
148
- static translate(tx, ty) {
149
- return new _AffineTransform([1, 0, tx, 0, 1, ty]);
150
- }
151
- static multiply(...[first, ...rest]) {
152
- if (!first) return _AffineTransform.identity;
153
- return rest.reduce((result, item) => result.prepend(item), first);
154
- }
155
- get a() {
156
- return this.m00;
157
- }
158
- get b() {
159
- return this.m10;
160
- }
161
- get c() {
162
- return this.m01;
163
- }
164
- get d() {
165
- return this.m11;
166
- }
167
- get tx() {
168
- return this.m02;
169
- }
170
- get ty() {
171
- return this.m12;
172
- }
173
- get scaleComponents() {
174
- return { x: this.a, y: this.d };
175
- }
176
- get translationComponents() {
177
- return { x: this.tx, y: this.ty };
178
- }
179
- get skewComponents() {
180
- return { x: this.c, y: this.b };
181
- }
182
- toString() {
183
- return `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`;
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
- // Annotate the CommonJS export names for ESM import in node:
187
- 0 && (module.exports = {
188
- AffineTransform
189
- });
191
+ exports.AffineTransform = AffineTransform;