@zag-js/rect-utils 1.47.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
package/dist/clamp.js
CHANGED
|
@@ -1,51 +1,28 @@
|
|
|
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/clamp.ts
|
|
21
|
-
var clamp_exports = {};
|
|
22
|
-
__export(clamp_exports, {
|
|
23
|
-
clampPoint: () => clampPoint,
|
|
24
|
-
clampSize: () => clampSize
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
// src/clamp.ts
|
|
6
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
7
|
+
const clampPoint = (position, size, boundaryRect) => {
|
|
8
|
+
return {
|
|
9
|
+
x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
|
|
10
|
+
y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
|
|
11
|
+
};
|
|
32
12
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
13
|
+
const defaultMinSize = {
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0
|
|
36
16
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
const defaultMaxSize = {
|
|
18
|
+
width: 1e400,
|
|
19
|
+
height: 1e400
|
|
40
20
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
|
|
22
|
+
return {
|
|
23
|
+
width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
|
|
24
|
+
height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
|
|
25
|
+
};
|
|
46
26
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
clampPoint,
|
|
50
|
-
clampSize
|
|
51
|
-
});
|
|
27
|
+
exports.clampPoint = clampPoint;
|
|
28
|
+
exports.clampSize = clampSize;
|
package/dist/clamp.mjs
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/clamp.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
3
|
+
const clampPoint = (position, size, boundaryRect) => {
|
|
4
|
+
return {
|
|
5
|
+
x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
|
|
6
|
+
y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
|
|
7
|
+
};
|
|
9
8
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const defaultMinSize = {
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const defaultMaxSize = {
|
|
14
|
+
width: 1e400,
|
|
15
|
+
height: 1e400
|
|
17
16
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
clampPoint,
|
|
26
|
-
clampSize
|
|
17
|
+
const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
|
|
18
|
+
return {
|
|
19
|
+
width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
|
|
20
|
+
height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
|
|
21
|
+
};
|
|
27
22
|
};
|
|
23
|
+
export { clampPoint, clampSize };
|
package/dist/closest.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Point, Rect, RectSide } from
|
|
2
|
-
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
5
|
-
declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
|
|
6
|
-
|
|
7
|
-
export { closest, closestSideToPoint, closestSideToRect };
|
|
1
|
+
import { Point, Rect, RectSide } from "./types.mjs";
|
|
2
|
+
export declare function closest(...pts: Point[]): (a: Point) => Point;
|
|
3
|
+
export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
|
|
4
|
+
export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
|
package/dist/closest.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Point, Rect, RectSide } from
|
|
2
|
-
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
5
|
-
declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
|
|
6
|
-
|
|
7
|
-
export { closest, closestSideToPoint, closestSideToRect };
|
|
1
|
+
import { Point, Rect, RectSide } from "./types.js";
|
|
2
|
+
export declare function closest(...pts: Point[]): (a: Point) => Point;
|
|
3
|
+
export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
|
|
4
|
+
export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
|
package/dist/closest.js
CHANGED
|
@@ -1,69 +1,42 @@
|
|
|
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/closest.ts
|
|
21
|
-
var closest_exports = {};
|
|
22
|
-
__export(closest_exports, {
|
|
23
|
-
closest: () => closest,
|
|
24
|
-
closestSideToPoint: () => closestSideToPoint,
|
|
25
|
-
closestSideToRect: () => closestSideToRect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
26
4
|
});
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
const require_distance = require("./distance.js");
|
|
6
|
+
// src/closest.ts
|
|
29
7
|
function closest(...pts) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
return (a) => {
|
|
9
|
+
const ds = pts.map((b) => require_distance.distance(b, a));
|
|
10
|
+
const c = Math.min.apply(Math, ds);
|
|
11
|
+
return pts[ds.indexOf(c)];
|
|
12
|
+
};
|
|
35
13
|
}
|
|
36
14
|
function closestSideToRect(ref, r) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
if (r.maxX <= ref.minX) return "left";
|
|
16
|
+
if (r.minX >= ref.maxX) return "right";
|
|
17
|
+
if (r.maxY <= ref.minY) return "top";
|
|
18
|
+
if (r.minY >= ref.maxY) return "bottom";
|
|
19
|
+
return "left";
|
|
42
20
|
}
|
|
43
21
|
function closestSideToPoint(ref, p) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return side;
|
|
22
|
+
const { x, y } = p;
|
|
23
|
+
const dl = x - ref.minX;
|
|
24
|
+
const dr = ref.maxX - x;
|
|
25
|
+
const dt = y - ref.minY;
|
|
26
|
+
const db = ref.maxY - y;
|
|
27
|
+
let closest = dl;
|
|
28
|
+
let side = "left";
|
|
29
|
+
if (dr < closest) {
|
|
30
|
+
closest = dr;
|
|
31
|
+
side = "right";
|
|
32
|
+
}
|
|
33
|
+
if (dt < closest) {
|
|
34
|
+
closest = dt;
|
|
35
|
+
side = "top";
|
|
36
|
+
}
|
|
37
|
+
if (db < closest) side = "bottom";
|
|
38
|
+
return side;
|
|
63
39
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
closestSideToPoint,
|
|
68
|
-
closestSideToRect
|
|
69
|
-
});
|
|
40
|
+
exports.closest = closest;
|
|
41
|
+
exports.closestSideToPoint = closestSideToPoint;
|
|
42
|
+
exports.closestSideToRect = closestSideToRect;
|
package/dist/closest.mjs
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
|
-
// src/closest.ts
|
|
4
1
|
import { distance } from "./distance.mjs";
|
|
2
|
+
// src/closest.ts
|
|
5
3
|
function closest(...pts) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
return (a) => {
|
|
5
|
+
const ds = pts.map((b) => distance(b, a));
|
|
6
|
+
const c = Math.min.apply(Math, ds);
|
|
7
|
+
return pts[ds.indexOf(c)];
|
|
8
|
+
};
|
|
11
9
|
}
|
|
12
10
|
function closestSideToRect(ref, r) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
if (r.maxX <= ref.minX) return "left";
|
|
12
|
+
if (r.minX >= ref.maxX) return "right";
|
|
13
|
+
if (r.maxY <= ref.minY) return "top";
|
|
14
|
+
if (r.minY >= ref.maxY) return "bottom";
|
|
15
|
+
return "left";
|
|
18
16
|
}
|
|
19
17
|
function closestSideToPoint(ref, p) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return side;
|
|
18
|
+
const { x, y } = p;
|
|
19
|
+
const dl = x - ref.minX;
|
|
20
|
+
const dr = ref.maxX - x;
|
|
21
|
+
const dt = y - ref.minY;
|
|
22
|
+
const db = ref.maxY - y;
|
|
23
|
+
let closest = dl;
|
|
24
|
+
let side = "left";
|
|
25
|
+
if (dr < closest) {
|
|
26
|
+
closest = dr;
|
|
27
|
+
side = "right";
|
|
28
|
+
}
|
|
29
|
+
if (dt < closest) {
|
|
30
|
+
closest = dt;
|
|
31
|
+
side = "top";
|
|
32
|
+
}
|
|
33
|
+
if (db < closest) side = "bottom";
|
|
34
|
+
return side;
|
|
39
35
|
}
|
|
40
|
-
export {
|
|
41
|
-
closest,
|
|
42
|
-
closestSideToPoint,
|
|
43
|
-
closestSideToRect
|
|
44
|
-
};
|
|
36
|
+
export { closest, closestSideToPoint, closestSideToRect };
|
package/dist/compass.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Point } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const
|
|
5
|
-
declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
|
|
6
|
-
|
|
7
|
-
export { type CompassDirection, compassDirectionMap, oppositeDirectionMap };
|
|
1
|
+
import { Point } from "./types.mjs";
|
|
2
|
+
export type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
|
|
3
|
+
export declare const compassDirectionMap: Record<CompassDirection, Point>;
|
|
4
|
+
export declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
|
package/dist/compass.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Point } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const
|
|
5
|
-
declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
|
|
6
|
-
|
|
7
|
-
export { type CompassDirection, compassDirectionMap, oppositeDirectionMap };
|
|
1
|
+
import { Point } from "./types.js";
|
|
2
|
+
export type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
|
|
3
|
+
export declare const compassDirectionMap: Record<CompassDirection, Point>;
|
|
4
|
+
export declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
|
package/dist/compass.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
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/compass.ts
|
|
21
|
-
var compass_exports = {};
|
|
22
|
-
__export(compass_exports, {
|
|
23
|
-
compassDirectionMap: () => compassDirectionMap,
|
|
24
|
-
oppositeDirectionMap: () => oppositeDirectionMap
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
5
|
+
// src/compass.ts
|
|
6
|
+
const compassDirectionMap = {
|
|
7
|
+
n: {
|
|
8
|
+
x: .5,
|
|
9
|
+
y: 0
|
|
10
|
+
},
|
|
11
|
+
ne: {
|
|
12
|
+
x: 1,
|
|
13
|
+
y: 0
|
|
14
|
+
},
|
|
15
|
+
e: {
|
|
16
|
+
x: 1,
|
|
17
|
+
y: .5
|
|
18
|
+
},
|
|
19
|
+
se: {
|
|
20
|
+
x: 1,
|
|
21
|
+
y: 1
|
|
22
|
+
},
|
|
23
|
+
s: {
|
|
24
|
+
x: .5,
|
|
25
|
+
y: 1
|
|
26
|
+
},
|
|
27
|
+
sw: {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 1
|
|
30
|
+
},
|
|
31
|
+
w: {
|
|
32
|
+
x: 0,
|
|
33
|
+
y: .5
|
|
34
|
+
},
|
|
35
|
+
nw: {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 0
|
|
38
|
+
}
|
|
36
39
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const oppositeDirectionMap = {
|
|
41
|
+
n: "s",
|
|
42
|
+
ne: "sw",
|
|
43
|
+
e: "w",
|
|
44
|
+
se: "nw",
|
|
45
|
+
s: "n",
|
|
46
|
+
sw: "ne",
|
|
47
|
+
w: "e",
|
|
48
|
+
nw: "se"
|
|
46
49
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
compassDirectionMap,
|
|
50
|
-
oppositeDirectionMap
|
|
51
|
-
});
|
|
50
|
+
exports.compassDirectionMap = compassDirectionMap;
|
|
51
|
+
exports.oppositeDirectionMap = oppositeDirectionMap;
|
package/dist/compass.mjs
CHANGED
|
@@ -1,27 +1,46 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/compass.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
const compassDirectionMap = {
|
|
3
|
+
n: {
|
|
4
|
+
x: .5,
|
|
5
|
+
y: 0
|
|
6
|
+
},
|
|
7
|
+
ne: {
|
|
8
|
+
x: 1,
|
|
9
|
+
y: 0
|
|
10
|
+
},
|
|
11
|
+
e: {
|
|
12
|
+
x: 1,
|
|
13
|
+
y: .5
|
|
14
|
+
},
|
|
15
|
+
se: {
|
|
16
|
+
x: 1,
|
|
17
|
+
y: 1
|
|
18
|
+
},
|
|
19
|
+
s: {
|
|
20
|
+
x: .5,
|
|
21
|
+
y: 1
|
|
22
|
+
},
|
|
23
|
+
sw: {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 1
|
|
26
|
+
},
|
|
27
|
+
w: {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: .5
|
|
30
|
+
},
|
|
31
|
+
nw: {
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0
|
|
34
|
+
}
|
|
13
35
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
compassDirectionMap,
|
|
26
|
-
oppositeDirectionMap
|
|
36
|
+
const oppositeDirectionMap = {
|
|
37
|
+
n: "s",
|
|
38
|
+
ne: "sw",
|
|
39
|
+
e: "w",
|
|
40
|
+
se: "nw",
|
|
41
|
+
s: "n",
|
|
42
|
+
sw: "ne",
|
|
43
|
+
w: "e",
|
|
44
|
+
nw: "se"
|
|
27
45
|
};
|
|
46
|
+
export { compassDirectionMap, oppositeDirectionMap };
|
package/dist/constrain.d.mts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { RectInit } from
|
|
2
|
-
|
|
3
|
-
declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
|
|
4
|
-
|
|
5
|
-
export { constrainRect };
|
|
1
|
+
import { RectInit } from "./types.mjs";
|
|
2
|
+
export declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
|
package/dist/constrain.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { RectInit } from
|
|
2
|
-
|
|
3
|
-
declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
|
|
4
|
-
|
|
5
|
-
export { constrainRect };
|
|
1
|
+
import { RectInit } from "./types.js";
|
|
2
|
+
export declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
|
package/dist/constrain.js
CHANGED
|
@@ -1,39 +1,14 @@
|
|
|
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/constrain.ts
|
|
21
|
-
var constrain_exports = {};
|
|
22
|
-
__export(constrain_exports, {
|
|
23
|
-
constrainRect: () => constrainRect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
height: Math.min(rect.height, boundary.height)
|
|
34
|
-
};
|
|
5
|
+
// src/constrain.ts
|
|
6
|
+
const constrainRect = (rect, boundary) => {
|
|
7
|
+
return {
|
|
8
|
+
x: Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width)),
|
|
9
|
+
y: Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height)),
|
|
10
|
+
width: Math.min(rect.width, boundary.width),
|
|
11
|
+
height: Math.min(rect.height, boundary.height)
|
|
12
|
+
};
|
|
35
13
|
};
|
|
36
|
-
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
constrainRect
|
|
39
|
-
});
|
|
14
|
+
exports.constrainRect = constrainRect;
|
package/dist/constrain.mjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/constrain.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
height: Math.min(rect.height, boundary.height)
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
constrainRect
|
|
2
|
+
const constrainRect = (rect, boundary) => {
|
|
3
|
+
return {
|
|
4
|
+
x: Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width)),
|
|
5
|
+
y: Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height)),
|
|
6
|
+
width: Math.min(rect.width, boundary.width),
|
|
7
|
+
height: Math.min(rect.height, boundary.height)
|
|
8
|
+
};
|
|
16
9
|
};
|
|
10
|
+
export { constrainRect };
|
package/dist/contains.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
5
|
-
declare function contains(r: Rect, v: Rect | Point): boolean;
|
|
6
|
-
|
|
7
|
-
export { contains, containsPoint, containsRect };
|
|
1
|
+
import { Point, Rect } from "./types.mjs";
|
|
2
|
+
export declare function containsPoint(r: Rect, p: Point): boolean;
|
|
3
|
+
export declare function containsRect(a: Rect, b: Rect): boolean;
|
|
4
|
+
export declare function contains(r: Rect, v: Rect | Point): boolean;
|
package/dist/contains.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
5
|
-
declare function contains(r: Rect, v: Rect | Point): boolean;
|
|
6
|
-
|
|
7
|
-
export { contains, containsPoint, containsRect };
|
|
1
|
+
import { Point, Rect } from "./types.js";
|
|
2
|
+
export declare function containsPoint(r: Rect, p: Point): boolean;
|
|
3
|
+
export declare function containsRect(a: Rect, b: Rect): boolean;
|
|
4
|
+
export declare function contains(r: Rect, v: Rect | Point): boolean;
|