@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/from-window.js
CHANGED
|
@@ -1,49 +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/from-window.ts
|
|
21
|
-
var from_window_exports = {};
|
|
22
|
-
__export(from_window_exports, {
|
|
23
|
-
getViewportRect: () => getViewportRect,
|
|
24
|
-
getWindowRect: () => getWindowRect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
const require_rect = require("./rect.js");
|
|
6
|
+
// src/from-window.ts
|
|
7
|
+
/**
|
|
8
|
+
* Creates a rectangle from window object
|
|
9
|
+
*/
|
|
28
10
|
function getWindowRect(win, opts = {}) {
|
|
29
|
-
|
|
11
|
+
return require_rect.createRect(getViewportRect(win, opts));
|
|
30
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the rect of the window with the option to exclude the scrollbar
|
|
15
|
+
*/
|
|
31
16
|
function getViewportRect(win, opts) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
17
|
+
const { excludeScrollbar = false } = opts;
|
|
18
|
+
const { innerWidth, innerHeight, document: doc, visualViewport } = win;
|
|
19
|
+
const rect = {
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
width: visualViewport?.width || innerWidth,
|
|
23
|
+
height: visualViewport?.height || innerHeight
|
|
24
|
+
};
|
|
25
|
+
if (excludeScrollbar) {
|
|
26
|
+
const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
|
|
27
|
+
const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
|
|
28
|
+
rect.width -= scrollbarWidth;
|
|
29
|
+
rect.height -= scrollbarHeight;
|
|
30
|
+
}
|
|
31
|
+
return rect;
|
|
44
32
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
getViewportRect,
|
|
48
|
-
getWindowRect
|
|
49
|
-
});
|
|
33
|
+
exports.getViewportRect = getViewportRect;
|
|
34
|
+
exports.getWindowRect = getWindowRect;
|
package/dist/from-window.mjs
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
|
-
// src/from-window.ts
|
|
4
1
|
import { createRect } from "./rect.mjs";
|
|
2
|
+
// src/from-window.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a rectangle from window object
|
|
5
|
+
*/
|
|
5
6
|
function getWindowRect(win, opts = {}) {
|
|
6
|
-
|
|
7
|
+
return createRect(getViewportRect(win, opts));
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Get the rect of the window with the option to exclude the scrollbar
|
|
11
|
+
*/
|
|
8
12
|
function getViewportRect(win, opts) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const { excludeScrollbar = false } = opts;
|
|
14
|
+
const { innerWidth, innerHeight, document: doc, visualViewport } = win;
|
|
15
|
+
const rect = {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: visualViewport?.width || innerWidth,
|
|
19
|
+
height: visualViewport?.height || innerHeight
|
|
20
|
+
};
|
|
21
|
+
if (excludeScrollbar) {
|
|
22
|
+
const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
|
|
23
|
+
const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
|
|
24
|
+
rect.width -= scrollbarWidth;
|
|
25
|
+
rect.height -= scrollbarHeight;
|
|
26
|
+
}
|
|
27
|
+
return rect;
|
|
21
28
|
}
|
|
22
|
-
export {
|
|
23
|
-
getViewportRect,
|
|
24
|
-
getWindowRect
|
|
25
|
-
};
|
|
29
|
+
export { getViewportRect, getWindowRect };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { AffineTransform } from "./affine-transform.mjs";
|
|
2
|
+
import { alignRect } from "./align.mjs";
|
|
3
|
+
import { getPointAngle } from "./angle.mjs";
|
|
4
|
+
import { clampPoint, clampSize } from "./clamp.mjs";
|
|
5
|
+
import { closest, closestSideToPoint, closestSideToRect } from "./closest.mjs";
|
|
6
|
+
import { constrainRect } from "./constrain.mjs";
|
|
7
|
+
import { contains, containsPoint, containsRect } from "./contains.mjs";
|
|
8
|
+
import { DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from "./distance.mjs";
|
|
9
|
+
import { isPointEqual, isRectEqual, isSizeEqual } from "./equality.mjs";
|
|
10
|
+
import { ElementRectOptions, getElementRect } from "./from-element.mjs";
|
|
11
|
+
import { getRectFromPoints } from "./from-points.mjs";
|
|
12
|
+
import { fromRange } from "./from-range.mjs";
|
|
13
|
+
import { getRotationRect, rotate, toRad } from "./from-rotation.mjs";
|
|
14
|
+
import { WindowRectOptions, getViewportRect, getWindowRect } from "./from-window.mjs";
|
|
15
|
+
import { collisions, intersection, intersects } from "./intersection.mjs";
|
|
16
|
+
import { expand, inset, isSymmetric, shift, shrink } from "./operations.mjs";
|
|
17
|
+
import { debugPolygon, getElementPolygon, isPointInPolygon } from "./polygon.mjs";
|
|
18
|
+
import { addPoints, createPoint, createRect, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, subtractPoints } from "./rect.mjs";
|
|
19
|
+
import { resizeRect } from "./resize.mjs";
|
|
20
|
+
import { AlignOptions, Bounds, CenterPoint, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, ScalingOptions, Size, SymmetricRectInset, VAlign } from "./types.mjs";
|
|
21
|
+
import { union } from "./union.mjs";
|
|
22
|
+
export { AffineTransform, AlignOptions, Bounds, CenterPoint, DistanceValue, ElementRectOptions, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, ScalingOptions, Size, SymmetricRectInset, VAlign, WindowRectOptions, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { AffineTransform } from "./affine-transform.js";
|
|
2
|
+
import { alignRect } from "./align.js";
|
|
3
|
+
import { getPointAngle } from "./angle.js";
|
|
4
|
+
import { clampPoint, clampSize } from "./clamp.js";
|
|
5
|
+
import { closest, closestSideToPoint, closestSideToRect } from "./closest.js";
|
|
6
|
+
import { constrainRect } from "./constrain.js";
|
|
7
|
+
import { contains, containsPoint, containsRect } from "./contains.js";
|
|
8
|
+
import { DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from "./distance.js";
|
|
9
|
+
import { isPointEqual, isRectEqual, isSizeEqual } from "./equality.js";
|
|
10
|
+
import { ElementRectOptions, getElementRect } from "./from-element.js";
|
|
11
|
+
import { getRectFromPoints } from "./from-points.js";
|
|
12
|
+
import { fromRange } from "./from-range.js";
|
|
13
|
+
import { getRotationRect, rotate, toRad } from "./from-rotation.js";
|
|
14
|
+
import { WindowRectOptions, getViewportRect, getWindowRect } from "./from-window.js";
|
|
15
|
+
import { collisions, intersection, intersects } from "./intersection.js";
|
|
16
|
+
import { expand, inset, isSymmetric, shift, shrink } from "./operations.js";
|
|
17
|
+
import { debugPolygon, getElementPolygon, isPointInPolygon } from "./polygon.js";
|
|
18
|
+
import { addPoints, createPoint, createRect, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, subtractPoints } from "./rect.js";
|
|
19
|
+
import { resizeRect } from "./resize.js";
|
|
20
|
+
import { AlignOptions, Bounds, CenterPoint, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, ScalingOptions, Size, SymmetricRectInset, VAlign } from "./types.js";
|
|
21
|
+
import { union } from "./union.js";
|
|
22
|
+
export { AffineTransform, AlignOptions, Bounds, CenterPoint, DistanceValue, ElementRectOptions, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, ScalingOptions, Size, SymmetricRectInset, VAlign, WindowRectOptions, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union };
|
package/dist/index.js
CHANGED
|
@@ -1,64 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
|
|
17
|
-
// src/index.ts
|
|
18
|
-
var index_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./affine-transform.js"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("./align.js"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./angle.js"), module.exports);
|
|
23
|
-
__reExport(index_exports, require("./clamp.js"), module.exports);
|
|
24
|
-
__reExport(index_exports, require("./closest.js"), module.exports);
|
|
25
|
-
__reExport(index_exports, require("./constrain.js"), module.exports);
|
|
26
|
-
__reExport(index_exports, require("./contains.js"), module.exports);
|
|
27
|
-
__reExport(index_exports, require("./distance.js"), module.exports);
|
|
28
|
-
__reExport(index_exports, require("./equality.js"), module.exports);
|
|
29
|
-
__reExport(index_exports, require("./from-element.js"), module.exports);
|
|
30
|
-
__reExport(index_exports, require("./from-points.js"), module.exports);
|
|
31
|
-
__reExport(index_exports, require("./from-range.js"), module.exports);
|
|
32
|
-
__reExport(index_exports, require("./from-rotation.js"), module.exports);
|
|
33
|
-
__reExport(index_exports, require("./from-window.js"), module.exports);
|
|
34
|
-
__reExport(index_exports, require("./intersection.js"), module.exports);
|
|
35
|
-
__reExport(index_exports, require("./operations.js"), module.exports);
|
|
36
|
-
__reExport(index_exports, require("./polygon.js"), module.exports);
|
|
37
|
-
__reExport(index_exports, require("./rect.js"), module.exports);
|
|
38
|
-
__reExport(index_exports, require("./resize.js"), module.exports);
|
|
39
|
-
__reExport(index_exports, require("./types.js"), module.exports);
|
|
40
|
-
__reExport(index_exports, require("./union.js"), module.exports);
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
...require("./affine-transform.js"),
|
|
44
|
-
...require("./align.js"),
|
|
45
|
-
...require("./angle.js"),
|
|
46
|
-
...require("./clamp.js"),
|
|
47
|
-
...require("./closest.js"),
|
|
48
|
-
...require("./constrain.js"),
|
|
49
|
-
...require("./contains.js"),
|
|
50
|
-
...require("./distance.js"),
|
|
51
|
-
...require("./equality.js"),
|
|
52
|
-
...require("./from-element.js"),
|
|
53
|
-
...require("./from-points.js"),
|
|
54
|
-
...require("./from-range.js"),
|
|
55
|
-
...require("./from-rotation.js"),
|
|
56
|
-
...require("./from-window.js"),
|
|
57
|
-
...require("./intersection.js"),
|
|
58
|
-
...require("./operations.js"),
|
|
59
|
-
...require("./polygon.js"),
|
|
60
|
-
...require("./rect.js"),
|
|
61
|
-
...require("./resize.js"),
|
|
62
|
-
...require("./types.js"),
|
|
63
|
-
...require("./union.js")
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
64
4
|
});
|
|
5
|
+
const require_affine_transform = require("./affine-transform.js");
|
|
6
|
+
const require_align = require("./align.js");
|
|
7
|
+
const require_angle = require("./angle.js");
|
|
8
|
+
const require_clamp = require("./clamp.js");
|
|
9
|
+
const require_closest = require("./closest.js");
|
|
10
|
+
const require_constrain = require("./constrain.js");
|
|
11
|
+
const require_contains = require("./contains.js");
|
|
12
|
+
const require_distance = require("./distance.js");
|
|
13
|
+
const require_equality = require("./equality.js");
|
|
14
|
+
const require_from_element = require("./from-element.js");
|
|
15
|
+
const require_from_points = require("./from-points.js");
|
|
16
|
+
const require_from_range = require("./from-range.js");
|
|
17
|
+
const require_from_rotation = require("./from-rotation.js");
|
|
18
|
+
const require_from_window = require("./from-window.js");
|
|
19
|
+
const require_intersection = require("./intersection.js");
|
|
20
|
+
const require_operations = require("./operations.js");
|
|
21
|
+
const require_polygon = require("./polygon.js");
|
|
22
|
+
const require_rect = require("./rect.js");
|
|
23
|
+
const require_resize = require("./resize.js");
|
|
24
|
+
const require_union = require("./union.js");
|
|
25
|
+
exports.AffineTransform = require_affine_transform.AffineTransform;
|
|
26
|
+
exports.addPoints = require_rect.addPoints;
|
|
27
|
+
exports.alignRect = require_align.alignRect;
|
|
28
|
+
exports.clampPoint = require_clamp.clampPoint;
|
|
29
|
+
exports.clampSize = require_clamp.clampSize;
|
|
30
|
+
exports.closest = require_closest.closest;
|
|
31
|
+
exports.closestSideToPoint = require_closest.closestSideToPoint;
|
|
32
|
+
exports.closestSideToRect = require_closest.closestSideToRect;
|
|
33
|
+
exports.collisions = require_intersection.collisions;
|
|
34
|
+
exports.constrainRect = require_constrain.constrainRect;
|
|
35
|
+
exports.contains = require_contains.contains;
|
|
36
|
+
exports.containsPoint = require_contains.containsPoint;
|
|
37
|
+
exports.containsRect = require_contains.containsRect;
|
|
38
|
+
exports.createPoint = require_rect.createPoint;
|
|
39
|
+
exports.createRect = require_rect.createRect;
|
|
40
|
+
exports.debugPolygon = require_polygon.debugPolygon;
|
|
41
|
+
exports.distance = require_distance.distance;
|
|
42
|
+
exports.distanceBtwEdges = require_distance.distanceBtwEdges;
|
|
43
|
+
exports.distanceFromPoint = require_distance.distanceFromPoint;
|
|
44
|
+
exports.distanceFromRect = require_distance.distanceFromRect;
|
|
45
|
+
exports.expand = require_operations.expand;
|
|
46
|
+
exports.fromRange = require_from_range.fromRange;
|
|
47
|
+
exports.getElementPolygon = require_polygon.getElementPolygon;
|
|
48
|
+
exports.getElementRect = require_from_element.getElementRect;
|
|
49
|
+
exports.getPointAngle = require_angle.getPointAngle;
|
|
50
|
+
exports.getRectCenters = require_rect.getRectCenters;
|
|
51
|
+
exports.getRectCorners = require_rect.getRectCorners;
|
|
52
|
+
exports.getRectEdges = require_rect.getRectEdges;
|
|
53
|
+
exports.getRectFromPoints = require_from_points.getRectFromPoints;
|
|
54
|
+
exports.getRotationRect = require_from_rotation.getRotationRect;
|
|
55
|
+
exports.getViewportRect = require_from_window.getViewportRect;
|
|
56
|
+
exports.getWindowRect = require_from_window.getWindowRect;
|
|
57
|
+
exports.inset = require_operations.inset;
|
|
58
|
+
exports.intersection = require_intersection.intersection;
|
|
59
|
+
exports.intersects = require_intersection.intersects;
|
|
60
|
+
exports.isPoint = require_rect.isPoint;
|
|
61
|
+
exports.isPointEqual = require_equality.isPointEqual;
|
|
62
|
+
exports.isPointInPolygon = require_polygon.isPointInPolygon;
|
|
63
|
+
exports.isRect = require_rect.isRect;
|
|
64
|
+
exports.isRectEqual = require_equality.isRectEqual;
|
|
65
|
+
exports.isSizeEqual = require_equality.isSizeEqual;
|
|
66
|
+
exports.isSymmetric = require_operations.isSymmetric;
|
|
67
|
+
exports.resizeRect = require_resize.resizeRect;
|
|
68
|
+
exports.rotate = require_from_rotation.rotate;
|
|
69
|
+
exports.shift = require_operations.shift;
|
|
70
|
+
exports.shrink = require_operations.shrink;
|
|
71
|
+
exports.subtractPoints = require_rect.subtractPoints;
|
|
72
|
+
exports.toRad = require_from_rotation.toRad;
|
|
73
|
+
exports.union = require_union.union;
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
export * from "./union.mjs";
|
|
1
|
+
import { AffineTransform } from "./affine-transform.mjs";
|
|
2
|
+
import { alignRect } from "./align.mjs";
|
|
3
|
+
import { getPointAngle } from "./angle.mjs";
|
|
4
|
+
import { clampPoint, clampSize } from "./clamp.mjs";
|
|
5
|
+
import { closest, closestSideToPoint, closestSideToRect } from "./closest.mjs";
|
|
6
|
+
import { constrainRect } from "./constrain.mjs";
|
|
7
|
+
import { contains, containsPoint, containsRect } from "./contains.mjs";
|
|
8
|
+
import { distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from "./distance.mjs";
|
|
9
|
+
import { isPointEqual, isRectEqual, isSizeEqual } from "./equality.mjs";
|
|
10
|
+
import { getElementRect } from "./from-element.mjs";
|
|
11
|
+
import { getRectFromPoints } from "./from-points.mjs";
|
|
12
|
+
import { fromRange } from "./from-range.mjs";
|
|
13
|
+
import { getRotationRect, rotate, toRad } from "./from-rotation.mjs";
|
|
14
|
+
import { getViewportRect, getWindowRect } from "./from-window.mjs";
|
|
15
|
+
import { collisions, intersection, intersects } from "./intersection.mjs";
|
|
16
|
+
import { expand, inset, isSymmetric, shift, shrink } from "./operations.mjs";
|
|
17
|
+
import { debugPolygon, getElementPolygon, isPointInPolygon } from "./polygon.mjs";
|
|
18
|
+
import { addPoints, createPoint, createRect, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, subtractPoints } from "./rect.mjs";
|
|
19
|
+
import { resizeRect } from "./resize.mjs";
|
|
20
|
+
import { union } from "./union.mjs";
|
|
21
|
+
export { AffineTransform, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union };
|
package/dist/intersection.d.mts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { Rect, RectSide } from
|
|
2
|
-
|
|
1
|
+
import { Rect, RectSide } from "./types.mjs";
|
|
3
2
|
/**
|
|
4
3
|
* Checks if a Rect intersects another Rect
|
|
5
4
|
*/
|
|
6
|
-
declare function intersects(a: Rect, b: Rect): boolean;
|
|
5
|
+
export declare function intersects(a: Rect, b: Rect): boolean;
|
|
7
6
|
/**
|
|
8
7
|
* Returns a new Rect that represents the intersection between two Rects
|
|
9
8
|
*/
|
|
10
|
-
declare function intersection(a: Rect, b: Rect): Rect;
|
|
9
|
+
export declare function intersection(a: Rect, b: Rect): Rect;
|
|
11
10
|
/**
|
|
12
11
|
* Returns whether two rects collide along each edge
|
|
13
12
|
*/
|
|
14
|
-
declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
|
|
15
|
-
|
|
16
|
-
export { collisions, intersection, intersects };
|
|
13
|
+
export declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
|
package/dist/intersection.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { Rect, RectSide } from
|
|
2
|
-
|
|
1
|
+
import { Rect, RectSide } from "./types.js";
|
|
3
2
|
/**
|
|
4
3
|
* Checks if a Rect intersects another Rect
|
|
5
4
|
*/
|
|
6
|
-
declare function intersects(a: Rect, b: Rect): boolean;
|
|
5
|
+
export declare function intersects(a: Rect, b: Rect): boolean;
|
|
7
6
|
/**
|
|
8
7
|
* Returns a new Rect that represents the intersection between two Rects
|
|
9
8
|
*/
|
|
10
|
-
declare function intersection(a: Rect, b: Rect): Rect;
|
|
9
|
+
export declare function intersection(a: Rect, b: Rect): Rect;
|
|
11
10
|
/**
|
|
12
11
|
* Returns whether two rects collide along each edge
|
|
13
12
|
*/
|
|
14
|
-
declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
|
|
15
|
-
|
|
16
|
-
export { collisions, intersection, intersects };
|
|
13
|
+
export declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
|
package/dist/intersection.js
CHANGED
|
@@ -1,52 +1,41 @@
|
|
|
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/intersection.ts
|
|
21
|
-
var intersection_exports = {};
|
|
22
|
-
__export(intersection_exports, {
|
|
23
|
-
collisions: () => collisions,
|
|
24
|
-
intersection: () => intersection,
|
|
25
|
-
intersects: () => intersects
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
26
4
|
});
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
const require_rect = require("./rect.js");
|
|
6
|
+
// src/intersection.ts
|
|
7
|
+
/**
|
|
8
|
+
* Checks if a Rect intersects another Rect
|
|
9
|
+
*/
|
|
29
10
|
function intersects(a, b) {
|
|
30
|
-
|
|
11
|
+
return a.x < b.maxX && a.y < b.maxY && a.maxX > b.x && a.maxY > b.y;
|
|
31
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns a new Rect that represents the intersection between two Rects
|
|
15
|
+
*/
|
|
32
16
|
function intersection(a, b) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
const x = Math.max(a.x, b.x);
|
|
18
|
+
const y = Math.max(a.y, b.y);
|
|
19
|
+
const x2 = Math.min(a.x + a.width, b.x + b.width);
|
|
20
|
+
const y2 = Math.min(a.y + a.height, b.y + b.height);
|
|
21
|
+
return require_rect.createRect({
|
|
22
|
+
x,
|
|
23
|
+
y,
|
|
24
|
+
width: x2 - x,
|
|
25
|
+
height: y2 - y
|
|
26
|
+
});
|
|
38
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns whether two rects collide along each edge
|
|
30
|
+
*/
|
|
39
31
|
function collisions(a, b) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
return {
|
|
33
|
+
top: a.minY <= b.minY,
|
|
34
|
+
right: a.maxX >= b.maxX,
|
|
35
|
+
bottom: a.maxY >= b.maxY,
|
|
36
|
+
left: a.minX <= b.minX
|
|
37
|
+
};
|
|
46
38
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
intersection,
|
|
51
|
-
intersects
|
|
52
|
-
});
|
|
39
|
+
exports.collisions = collisions;
|
|
40
|
+
exports.intersection = intersection;
|
|
41
|
+
exports.intersects = intersects;
|
package/dist/intersection.mjs
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
|
-
// src/intersection.ts
|
|
4
1
|
import { createRect } from "./rect.mjs";
|
|
2
|
+
// src/intersection.ts
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a Rect intersects another Rect
|
|
5
|
+
*/
|
|
5
6
|
function intersects(a, b) {
|
|
6
|
-
|
|
7
|
+
return a.x < b.maxX && a.y < b.maxY && a.maxX > b.x && a.maxY > b.y;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns a new Rect that represents the intersection between two Rects
|
|
11
|
+
*/
|
|
8
12
|
function intersection(a, b) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const x = Math.max(a.x, b.x);
|
|
14
|
+
const y = Math.max(a.y, b.y);
|
|
15
|
+
const x2 = Math.min(a.x + a.width, b.x + b.width);
|
|
16
|
+
const y2 = Math.min(a.y + a.height, b.y + b.height);
|
|
17
|
+
return createRect({
|
|
18
|
+
x,
|
|
19
|
+
y,
|
|
20
|
+
width: x2 - x,
|
|
21
|
+
height: y2 - y
|
|
22
|
+
});
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether two rects collide along each edge
|
|
26
|
+
*/
|
|
15
27
|
function collisions(a, b) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
return {
|
|
29
|
+
top: a.minY <= b.minY,
|
|
30
|
+
right: a.maxX >= b.maxX,
|
|
31
|
+
bottom: a.maxY >= b.maxY,
|
|
32
|
+
left: a.minX <= b.minX
|
|
33
|
+
};
|
|
22
34
|
}
|
|
23
|
-
export {
|
|
24
|
-
collisions,
|
|
25
|
-
intersection,
|
|
26
|
-
intersects
|
|
27
|
-
};
|
|
35
|
+
export { collisions, intersection, intersects };
|
package/dist/operations.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
declare function
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
declare function shift(r: Rect, o: Partial<Point>): Rect;
|
|
8
|
-
|
|
9
|
-
export { expand, inset, isSymmetric, shift, shrink };
|
|
1
|
+
import { Point, Rect, RectInset, SymmetricRectInset } from "./types.mjs";
|
|
2
|
+
export declare const isSymmetric: (v: any) => v is SymmetricRectInset;
|
|
3
|
+
export declare function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect;
|
|
4
|
+
export declare function expand(r: Rect, v: number | SymmetricRectInset): Rect;
|
|
5
|
+
export declare function shrink(r: Rect, v: number | SymmetricRectInset): Rect;
|
|
6
|
+
export declare function shift(r: Rect, o: Partial<Point>): Rect;
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
declare function
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
declare function shift(r: Rect, o: Partial<Point>): Rect;
|
|
8
|
-
|
|
9
|
-
export { expand, inset, isSymmetric, shift, shrink };
|
|
1
|
+
import { Point, Rect, RectInset, SymmetricRectInset } from "./types.js";
|
|
2
|
+
export declare const isSymmetric: (v: any) => v is SymmetricRectInset;
|
|
3
|
+
export declare function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect;
|
|
4
|
+
export declare function expand(r: Rect, v: number | SymmetricRectInset): Rect;
|
|
5
|
+
export declare function shrink(r: Rect, v: number | SymmetricRectInset): Rect;
|
|
6
|
+
export declare function shift(r: Rect, o: Partial<Point>): Rect;
|