@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
|
@@ -1,166 +1,187 @@
|
|
|
1
|
-
import
|
|
2
|
-
__publicField
|
|
3
|
-
} from "./chunk-QZ7TP4HQ.mjs";
|
|
4
|
-
|
|
1
|
+
import _defineProperty from "./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs";
|
|
5
2
|
// src/affine-transform.ts
|
|
6
|
-
var AffineTransform = class
|
|
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
|
-
|
|
3
|
+
var AffineTransform = class AffineTransform {
|
|
4
|
+
constructor([m00, m01, m02, m10, m11, m12] = [
|
|
5
|
+
0,
|
|
6
|
+
0,
|
|
7
|
+
0,
|
|
8
|
+
0,
|
|
9
|
+
0,
|
|
10
|
+
0
|
|
11
|
+
]) {
|
|
12
|
+
_defineProperty(this, "m00", void 0);
|
|
13
|
+
_defineProperty(this, "m01", void 0);
|
|
14
|
+
_defineProperty(this, "m02", void 0);
|
|
15
|
+
_defineProperty(this, "m10", void 0);
|
|
16
|
+
_defineProperty(this, "m11", void 0);
|
|
17
|
+
_defineProperty(this, "m12", void 0);
|
|
18
|
+
_defineProperty(this, "rotate", (...args) => {
|
|
19
|
+
return this.prepend(AffineTransform.rotate(...args));
|
|
20
|
+
});
|
|
21
|
+
_defineProperty(this, "scale", (...args) => {
|
|
22
|
+
return this.prepend(AffineTransform.scale(...args));
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "translate", (...args) => {
|
|
25
|
+
return this.prepend(AffineTransform.translate(...args));
|
|
26
|
+
});
|
|
27
|
+
this.m00 = m00;
|
|
28
|
+
this.m01 = m01;
|
|
29
|
+
this.m02 = m02;
|
|
30
|
+
this.m10 = m10;
|
|
31
|
+
this.m11 = m11;
|
|
32
|
+
this.m12 = m12;
|
|
33
|
+
}
|
|
34
|
+
applyTo(point) {
|
|
35
|
+
const { x, y } = point;
|
|
36
|
+
const { m00, m01, m02, m10, m11, m12 } = this;
|
|
37
|
+
return {
|
|
38
|
+
x: m00 * x + m01 * y + m02,
|
|
39
|
+
y: m10 * x + m11 * y + m12
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
prepend(other) {
|
|
43
|
+
return new AffineTransform([
|
|
44
|
+
this.m00 * other.m00 + this.m01 * other.m10,
|
|
45
|
+
this.m00 * other.m01 + this.m01 * other.m11,
|
|
46
|
+
this.m00 * other.m02 + this.m01 * other.m12 + this.m02,
|
|
47
|
+
this.m10 * other.m00 + this.m11 * other.m10,
|
|
48
|
+
this.m10 * other.m01 + this.m11 * other.m11,
|
|
49
|
+
this.m10 * other.m02 + this.m11 * other.m12 + this.m12
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
append(other) {
|
|
53
|
+
return new AffineTransform([
|
|
54
|
+
other.m00 * this.m00 + other.m01 * this.m10,
|
|
55
|
+
other.m00 * this.m01 + other.m01 * this.m11,
|
|
56
|
+
other.m00 * this.m02 + other.m01 * this.m12 + other.m02,
|
|
57
|
+
other.m10 * this.m00 + other.m11 * this.m10,
|
|
58
|
+
other.m10 * this.m01 + other.m11 * this.m11,
|
|
59
|
+
other.m10 * this.m02 + other.m11 * this.m12 + other.m12
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
get determinant() {
|
|
63
|
+
return this.m00 * this.m11 - this.m01 * this.m10;
|
|
64
|
+
}
|
|
65
|
+
get isInvertible() {
|
|
66
|
+
const det = this.determinant;
|
|
67
|
+
return isFinite(det) && isFinite(this.m02) && isFinite(this.m12) && det !== 0;
|
|
68
|
+
}
|
|
69
|
+
invert() {
|
|
70
|
+
const det = this.determinant;
|
|
71
|
+
return new AffineTransform([
|
|
72
|
+
this.m11 / det,
|
|
73
|
+
-this.m01 / det,
|
|
74
|
+
(this.m01 * this.m12 - this.m11 * this.m02) / det,
|
|
75
|
+
-this.m10 / det,
|
|
76
|
+
this.m00 / det,
|
|
77
|
+
(this.m10 * this.m02 - this.m00 * this.m12) / det
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
get array() {
|
|
81
|
+
return [
|
|
82
|
+
this.m00,
|
|
83
|
+
this.m01,
|
|
84
|
+
this.m02,
|
|
85
|
+
this.m10,
|
|
86
|
+
this.m11,
|
|
87
|
+
this.m12,
|
|
88
|
+
0,
|
|
89
|
+
0,
|
|
90
|
+
1
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
get float32Array() {
|
|
94
|
+
return new Float32Array(this.array);
|
|
95
|
+
}
|
|
96
|
+
static get identity() {
|
|
97
|
+
return new AffineTransform([
|
|
98
|
+
1,
|
|
99
|
+
0,
|
|
100
|
+
0,
|
|
101
|
+
0,
|
|
102
|
+
1,
|
|
103
|
+
0
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
static rotate(theta, origin) {
|
|
107
|
+
const rotation = new AffineTransform([
|
|
108
|
+
Math.cos(theta),
|
|
109
|
+
-Math.sin(theta),
|
|
110
|
+
0,
|
|
111
|
+
Math.sin(theta),
|
|
112
|
+
Math.cos(theta),
|
|
113
|
+
0
|
|
114
|
+
]);
|
|
115
|
+
if (origin && (origin.x !== 0 || origin.y !== 0)) return AffineTransform.multiply(AffineTransform.translate(origin.x, origin.y), rotation, AffineTransform.translate(-origin.x, -origin.y));
|
|
116
|
+
return rotation;
|
|
117
|
+
}
|
|
118
|
+
static scale(sx, sy = sx, origin = {
|
|
119
|
+
x: 0,
|
|
120
|
+
y: 0
|
|
121
|
+
}) {
|
|
122
|
+
const scale = new AffineTransform([
|
|
123
|
+
sx,
|
|
124
|
+
0,
|
|
125
|
+
0,
|
|
126
|
+
0,
|
|
127
|
+
sy,
|
|
128
|
+
0
|
|
129
|
+
]);
|
|
130
|
+
if (origin.x !== 0 || origin.y !== 0) return AffineTransform.multiply(AffineTransform.translate(origin.x, origin.y), scale, AffineTransform.translate(-origin.x, -origin.y));
|
|
131
|
+
return scale;
|
|
132
|
+
}
|
|
133
|
+
static translate(tx, ty) {
|
|
134
|
+
return new AffineTransform([
|
|
135
|
+
1,
|
|
136
|
+
0,
|
|
137
|
+
tx,
|
|
138
|
+
0,
|
|
139
|
+
1,
|
|
140
|
+
ty
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
static multiply(...[first, ...rest]) {
|
|
144
|
+
if (!first) return AffineTransform.identity;
|
|
145
|
+
return rest.reduce((result, item) => result.prepend(item), first);
|
|
146
|
+
}
|
|
147
|
+
get a() {
|
|
148
|
+
return this.m00;
|
|
149
|
+
}
|
|
150
|
+
get b() {
|
|
151
|
+
return this.m10;
|
|
152
|
+
}
|
|
153
|
+
get c() {
|
|
154
|
+
return this.m01;
|
|
155
|
+
}
|
|
156
|
+
get d() {
|
|
157
|
+
return this.m11;
|
|
158
|
+
}
|
|
159
|
+
get tx() {
|
|
160
|
+
return this.m02;
|
|
161
|
+
}
|
|
162
|
+
get ty() {
|
|
163
|
+
return this.m12;
|
|
164
|
+
}
|
|
165
|
+
get scaleComponents() {
|
|
166
|
+
return {
|
|
167
|
+
x: this.a,
|
|
168
|
+
y: this.d
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
get translationComponents() {
|
|
172
|
+
return {
|
|
173
|
+
x: this.tx,
|
|
174
|
+
y: this.ty
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
get skewComponents() {
|
|
178
|
+
return {
|
|
179
|
+
x: this.c,
|
|
180
|
+
y: this.b
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
toString() {
|
|
184
|
+
return `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`;
|
|
185
|
+
}
|
|
166
186
|
};
|
|
187
|
+
export { AffineTransform };
|
package/dist/align.d.mts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
|
|
4
|
-
|
|
5
|
-
export { alignRect };
|
|
1
|
+
import { AlignOptions, Rect } from "./types.mjs";
|
|
2
|
+
export declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
|
package/dist/align.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
|
|
4
|
-
|
|
5
|
-
export { alignRect };
|
|
1
|
+
import { AlignOptions, Rect } from "./types.js";
|
|
2
|
+
export declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
|
package/dist/align.js
CHANGED
|
@@ -1,51 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/align.ts
|
|
21
|
-
var align_exports = {};
|
|
22
|
-
__export(align_exports, {
|
|
23
|
-
alignRect: () => alignRect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
5
|
+
// src/align.ts
|
|
26
6
|
function hAlign(a, ref, h) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
let x = ref.minX;
|
|
8
|
+
if (h === "left-inside") x = ref.minX;
|
|
9
|
+
if (h === "left-outside") x = ref.minX - ref.width;
|
|
10
|
+
if (h === "right-inside") x = ref.maxX - ref.width;
|
|
11
|
+
if (h === "right-outside") x = ref.maxX;
|
|
12
|
+
if (h === "center") x = ref.midX - ref.width / 2;
|
|
13
|
+
return {
|
|
14
|
+
...a,
|
|
15
|
+
x
|
|
16
|
+
};
|
|
34
17
|
}
|
|
35
18
|
function vAlign(a, ref, v) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
let y = ref.minY;
|
|
20
|
+
if (v === "top-inside") y = ref.minY;
|
|
21
|
+
if (v === "top-outside") y = ref.minY - a.height;
|
|
22
|
+
if (v === "bottom-inside") y = ref.maxY - a.height;
|
|
23
|
+
if (v === "bottom-outside") y = ref.maxY;
|
|
24
|
+
if (v === "center") y = ref.midY - a.height / 2;
|
|
25
|
+
return {
|
|
26
|
+
...a,
|
|
27
|
+
y
|
|
28
|
+
};
|
|
43
29
|
}
|
|
44
30
|
function alignRect(a, ref, options) {
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
const { h, v } = options;
|
|
32
|
+
return vAlign(hAlign(a, ref, h), ref, v);
|
|
47
33
|
}
|
|
48
|
-
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
alignRect
|
|
51
|
-
});
|
|
34
|
+
exports.alignRect = alignRect;
|
package/dist/align.mjs
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/align.ts
|
|
4
2
|
function hAlign(a, ref, h) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
let x = ref.minX;
|
|
4
|
+
if (h === "left-inside") x = ref.minX;
|
|
5
|
+
if (h === "left-outside") x = ref.minX - ref.width;
|
|
6
|
+
if (h === "right-inside") x = ref.maxX - ref.width;
|
|
7
|
+
if (h === "right-outside") x = ref.maxX;
|
|
8
|
+
if (h === "center") x = ref.midX - ref.width / 2;
|
|
9
|
+
return {
|
|
10
|
+
...a,
|
|
11
|
+
x
|
|
12
|
+
};
|
|
12
13
|
}
|
|
13
14
|
function vAlign(a, ref, v) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
let y = ref.minY;
|
|
16
|
+
if (v === "top-inside") y = ref.minY;
|
|
17
|
+
if (v === "top-outside") y = ref.minY - a.height;
|
|
18
|
+
if (v === "bottom-inside") y = ref.maxY - a.height;
|
|
19
|
+
if (v === "bottom-outside") y = ref.maxY;
|
|
20
|
+
if (v === "center") y = ref.midY - a.height / 2;
|
|
21
|
+
return {
|
|
22
|
+
...a,
|
|
23
|
+
y
|
|
24
|
+
};
|
|
21
25
|
}
|
|
22
26
|
function alignRect(a, ref, options) {
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
const { h, v } = options;
|
|
28
|
+
return vAlign(hAlign(a, ref, h), ref, v);
|
|
25
29
|
}
|
|
26
|
-
export {
|
|
27
|
-
alignRect
|
|
28
|
-
};
|
|
30
|
+
export { alignRect };
|
package/dist/angle.d.mts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
|
|
4
|
-
|
|
5
|
-
export { getPointAngle };
|
|
1
|
+
import { Point, Rect } from "./types.mjs";
|
|
2
|
+
export declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
|
package/dist/angle.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
|
|
4
|
-
|
|
5
|
-
export { getPointAngle };
|
|
1
|
+
import { Point, Rect } from "./types.js";
|
|
2
|
+
export declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
|
package/dist/angle.js
CHANGED
|
@@ -1,35 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/angle.ts
|
|
21
|
-
var angle_exports = {};
|
|
22
|
-
__export(angle_exports, {
|
|
23
|
-
getPointAngle: () => getPointAngle
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
5
|
+
// src/angle.ts
|
|
26
6
|
function getPointAngle(rect, point, reference = rect.center) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return 360 - deg;
|
|
7
|
+
const x = point.x - reference.x;
|
|
8
|
+
const y = point.y - reference.y;
|
|
9
|
+
return 360 - (Math.atan2(x, y) * (180 / Math.PI) + 180);
|
|
31
10
|
}
|
|
32
|
-
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
getPointAngle
|
|
35
|
-
});
|
|
11
|
+
exports.getPointAngle = getPointAngle;
|
package/dist/angle.mjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/angle.ts
|
|
4
2
|
function getPointAngle(rect, point, reference = rect.center) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return 360 - deg;
|
|
3
|
+
const x = point.x - reference.x;
|
|
4
|
+
const y = point.y - reference.y;
|
|
5
|
+
return 360 - (Math.atan2(x, y) * (180 / Math.PI) + 180);
|
|
9
6
|
}
|
|
10
|
-
export {
|
|
11
|
-
getPointAngle
|
|
12
|
-
};
|
|
7
|
+
export { getPointAngle };
|
package/dist/clamp.d.mts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { Point,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
y: number;
|
|
1
|
+
import { Point, RectInit, Size } from "./types.mjs";
|
|
2
|
+
export declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
6
5
|
};
|
|
7
|
-
declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { clampPoint, clampSize };
|
|
6
|
+
export declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
package/dist/clamp.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { Point,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
y: number;
|
|
1
|
+
import { Point, RectInit, Size } from "./types.js";
|
|
2
|
+
export declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
6
5
|
};
|
|
7
|
-
declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { clampPoint, clampSize };
|
|
6
|
+
export declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|