@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.
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
@@ -1,66 +1,47 @@
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 __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/operations.ts
21
- var operations_exports = {};
22
- __export(operations_exports, {
23
- expand: () => expand,
24
- inset: () => inset,
25
- isSymmetric: () => isSymmetric,
26
- shift: () => shift,
27
- shrink: () => shrink
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
28
4
  });
29
- module.exports = __toCommonJS(operations_exports);
30
- var import_rect = require("./rect.js");
31
- var isSymmetric = (v) => "dx" in v || "dy" in v;
5
+ const require_rect = require("./rect.js");
6
+ // src/operations.ts
7
+ const isSymmetric = (v) => "dx" in v || "dy" in v;
32
8
  function inset(r, i) {
33
- const v = isSymmetric(i) ? { left: i.dx, right: i.dx, top: i.dy, bottom: i.dy } : i;
34
- const { top = 0, right = 0, bottom = 0, left = 0 } = v;
35
- return (0, import_rect.createRect)({
36
- x: r.x + left,
37
- y: r.y + top,
38
- width: r.width - left - right,
39
- height: r.height - top - bottom
40
- });
9
+ const { top = 0, right = 0, bottom = 0, left = 0 } = isSymmetric(i) ? {
10
+ left: i.dx,
11
+ right: i.dx,
12
+ top: i.dy,
13
+ bottom: i.dy
14
+ } : i;
15
+ return require_rect.createRect({
16
+ x: r.x + left,
17
+ y: r.y + top,
18
+ width: r.width - left - right,
19
+ height: r.height - top - bottom
20
+ });
41
21
  }
42
22
  function expand(r, v) {
43
- const value = typeof v === "number" ? { dx: -v, dy: -v } : v;
44
- return inset(r, value);
23
+ return inset(r, typeof v === "number" ? {
24
+ dx: -v,
25
+ dy: -v
26
+ } : v);
45
27
  }
46
28
  function shrink(r, v) {
47
- const value = typeof v === "number" ? { dx: -v, dy: -v } : v;
48
- return inset(r, value);
29
+ return inset(r, typeof v === "number" ? {
30
+ dx: -v,
31
+ dy: -v
32
+ } : v);
49
33
  }
50
34
  function shift(r, o) {
51
- const { x = 0, y = 0 } = o;
52
- return (0, import_rect.createRect)({
53
- x: r.x + x,
54
- y: r.y + y,
55
- width: r.width,
56
- height: r.height
57
- });
35
+ const { x = 0, y = 0 } = o;
36
+ return require_rect.createRect({
37
+ x: r.x + x,
38
+ y: r.y + y,
39
+ width: r.width,
40
+ height: r.height
41
+ });
58
42
  }
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- expand,
62
- inset,
63
- isSymmetric,
64
- shift,
65
- shrink
66
- });
43
+ exports.expand = expand;
44
+ exports.inset = inset;
45
+ exports.isSymmetric = isSymmetric;
46
+ exports.shift = shift;
47
+ exports.shrink = shrink;
@@ -1,39 +1,39 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/operations.ts
4
1
  import { createRect } from "./rect.mjs";
5
- var isSymmetric = (v) => "dx" in v || "dy" in v;
2
+ // src/operations.ts
3
+ const isSymmetric = (v) => "dx" in v || "dy" in v;
6
4
  function inset(r, i) {
7
- const v = isSymmetric(i) ? { left: i.dx, right: i.dx, top: i.dy, bottom: i.dy } : i;
8
- const { top = 0, right = 0, bottom = 0, left = 0 } = v;
9
- return createRect({
10
- x: r.x + left,
11
- y: r.y + top,
12
- width: r.width - left - right,
13
- height: r.height - top - bottom
14
- });
5
+ const { top = 0, right = 0, bottom = 0, left = 0 } = isSymmetric(i) ? {
6
+ left: i.dx,
7
+ right: i.dx,
8
+ top: i.dy,
9
+ bottom: i.dy
10
+ } : i;
11
+ return createRect({
12
+ x: r.x + left,
13
+ y: r.y + top,
14
+ width: r.width - left - right,
15
+ height: r.height - top - bottom
16
+ });
15
17
  }
16
18
  function expand(r, v) {
17
- const value = typeof v === "number" ? { dx: -v, dy: -v } : v;
18
- return inset(r, value);
19
+ return inset(r, typeof v === "number" ? {
20
+ dx: -v,
21
+ dy: -v
22
+ } : v);
19
23
  }
20
24
  function shrink(r, v) {
21
- const value = typeof v === "number" ? { dx: -v, dy: -v } : v;
22
- return inset(r, value);
25
+ return inset(r, typeof v === "number" ? {
26
+ dx: -v,
27
+ dy: -v
28
+ } : v);
23
29
  }
24
30
  function shift(r, o) {
25
- const { x = 0, y = 0 } = o;
26
- return createRect({
27
- x: r.x + x,
28
- y: r.y + y,
29
- width: r.width,
30
- height: r.height
31
- });
31
+ const { x = 0, y = 0 } = o;
32
+ return createRect({
33
+ x: r.x + x,
34
+ y: r.y + y,
35
+ width: r.width,
36
+ height: r.height
37
+ });
32
38
  }
33
- export {
34
- expand,
35
- inset,
36
- isSymmetric,
37
- shift,
38
- shrink
39
- };
39
+ export { expand, inset, isSymmetric, shift, shrink };
@@ -1,10 +1,7 @@
1
- import { Point, RectInit } from './types.mjs';
2
-
3
- declare function getElementPolygon(rectValue: RectInit, placement: string): {
4
- x: number;
5
- y: number;
1
+ import { Point, RectInit } from "./types.mjs";
2
+ export declare function getElementPolygon(rectValue: RectInit, placement: string): {
3
+ x: number;
4
+ y: number;
6
5
  }[] | undefined;
7
- declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
8
- declare function debugPolygon(polygon: Point[]): () => void;
9
-
10
- export { debugPolygon, getElementPolygon, isPointInPolygon };
6
+ export declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
7
+ export declare function debugPolygon(polygon: Point[]): () => void;
package/dist/polygon.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- import { Point, RectInit } from './types.js';
2
-
3
- declare function getElementPolygon(rectValue: RectInit, placement: string): {
4
- x: number;
5
- y: number;
1
+ import { Point, RectInit } from "./types.js";
2
+ export declare function getElementPolygon(rectValue: RectInit, placement: string): {
3
+ x: number;
4
+ y: number;
6
5
  }[] | undefined;
7
- declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
8
- declare function debugPolygon(polygon: Point[]): () => void;
9
-
10
- export { debugPolygon, getElementPolygon, isPointInPolygon };
6
+ export declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
7
+ export declare function debugPolygon(polygon: Point[]): () => void;
package/dist/polygon.js CHANGED
@@ -1,91 +1,82 @@
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 __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/polygon.ts
21
- var polygon_exports = {};
22
- __export(polygon_exports, {
23
- debugPolygon: () => debugPolygon,
24
- getElementPolygon: () => getElementPolygon,
25
- isPointInPolygon: () => isPointInPolygon
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
26
4
  });
27
- module.exports = __toCommonJS(polygon_exports);
28
- var import_rect = require("./rect.js");
5
+ const require_rect = require("./rect.js");
6
+ // src/polygon.ts
29
7
  function getElementPolygon(rectValue, placement) {
30
- const rect = (0, import_rect.createRect)(rectValue);
31
- const { top, right, left, bottom } = (0, import_rect.getRectCorners)(rect);
32
- const [base] = placement.split("-");
33
- return {
34
- top: [left, top, right, bottom],
35
- right: [top, right, bottom, left],
36
- bottom: [top, left, bottom, right],
37
- left: [right, top, left, bottom]
38
- }[base];
8
+ const rect = require_rect.createRect(rectValue);
9
+ const { top, right, left, bottom } = require_rect.getRectCorners(rect);
10
+ const [base] = placement.split("-");
11
+ return {
12
+ top: [
13
+ left,
14
+ top,
15
+ right,
16
+ bottom
17
+ ],
18
+ right: [
19
+ top,
20
+ right,
21
+ bottom,
22
+ left
23
+ ],
24
+ bottom: [
25
+ top,
26
+ left,
27
+ bottom,
28
+ right
29
+ ],
30
+ left: [
31
+ right,
32
+ top,
33
+ left,
34
+ bottom
35
+ ]
36
+ }[base];
39
37
  }
40
38
  function isPointInPolygon(polygon, point) {
41
- const { x, y } = point;
42
- let c = false;
43
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
44
- const xi = polygon[i].x;
45
- const yi = polygon[i].y;
46
- const xj = polygon[j].x;
47
- const yj = polygon[j].y;
48
- if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
49
- c = !c;
50
- }
51
- }
52
- return c;
39
+ const { x, y } = point;
40
+ let c = false;
41
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
42
+ const xi = polygon[i].x;
43
+ const yi = polygon[i].y;
44
+ const xj = polygon[j].x;
45
+ const yj = polygon[j].y;
46
+ if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) c = !c;
47
+ }
48
+ return c;
53
49
  }
54
50
  function createPolygonElement() {
55
- const id = "debug-polygon";
56
- const existingPolygon = document.getElementById(id);
57
- if (existingPolygon) {
58
- return existingPolygon;
59
- }
60
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
61
- Object.assign(svg.style, {
62
- top: "0",
63
- left: "0",
64
- width: "100%",
65
- height: "100%",
66
- opacity: "0.15",
67
- position: "fixed",
68
- pointerEvents: "none",
69
- fill: "red"
70
- });
71
- const polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
72
- polygon.setAttribute("id", id);
73
- polygon.setAttribute("points", "0,0 0,0");
74
- svg.appendChild(polygon);
75
- document.body.appendChild(svg);
76
- return polygon;
51
+ const id = "debug-polygon";
52
+ const existingPolygon = document.getElementById(id);
53
+ if (existingPolygon) return existingPolygon;
54
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
55
+ Object.assign(svg.style, {
56
+ top: "0",
57
+ left: "0",
58
+ width: "100%",
59
+ height: "100%",
60
+ opacity: "0.15",
61
+ position: "fixed",
62
+ pointerEvents: "none",
63
+ fill: "red"
64
+ });
65
+ const polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
66
+ polygon.setAttribute("id", id);
67
+ polygon.setAttribute("points", "0,0 0,0");
68
+ svg.appendChild(polygon);
69
+ document.body.appendChild(svg);
70
+ return polygon;
77
71
  }
78
72
  function debugPolygon(polygon) {
79
- const el = createPolygonElement();
80
- const points = polygon.map((point) => `${point.x},${point.y}`).join(" ");
81
- el.setAttribute("points", points);
82
- return () => {
83
- el.remove();
84
- };
73
+ const el = createPolygonElement();
74
+ const points = polygon.map((point) => `${point.x},${point.y}`).join(" ");
75
+ el.setAttribute("points", points);
76
+ return () => {
77
+ el.remove();
78
+ };
85
79
  }
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
88
- debugPolygon,
89
- getElementPolygon,
90
- isPointInPolygon
91
- });
80
+ exports.debugPolygon = debugPolygon;
81
+ exports.getElementPolygon = getElementPolygon;
82
+ exports.isPointInPolygon = isPointInPolygon;
package/dist/polygon.mjs CHANGED
@@ -1,66 +1,76 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/polygon.ts
4
1
  import { createRect, getRectCorners } from "./rect.mjs";
2
+ // src/polygon.ts
5
3
  function getElementPolygon(rectValue, placement) {
6
- const rect = createRect(rectValue);
7
- const { top, right, left, bottom } = getRectCorners(rect);
8
- const [base] = placement.split("-");
9
- return {
10
- top: [left, top, right, bottom],
11
- right: [top, right, bottom, left],
12
- bottom: [top, left, bottom, right],
13
- left: [right, top, left, bottom]
14
- }[base];
4
+ const rect = createRect(rectValue);
5
+ const { top, right, left, bottom } = getRectCorners(rect);
6
+ const [base] = placement.split("-");
7
+ return {
8
+ top: [
9
+ left,
10
+ top,
11
+ right,
12
+ bottom
13
+ ],
14
+ right: [
15
+ top,
16
+ right,
17
+ bottom,
18
+ left
19
+ ],
20
+ bottom: [
21
+ top,
22
+ left,
23
+ bottom,
24
+ right
25
+ ],
26
+ left: [
27
+ right,
28
+ top,
29
+ left,
30
+ bottom
31
+ ]
32
+ }[base];
15
33
  }
16
34
  function isPointInPolygon(polygon, point) {
17
- const { x, y } = point;
18
- let c = false;
19
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
20
- const xi = polygon[i].x;
21
- const yi = polygon[i].y;
22
- const xj = polygon[j].x;
23
- const yj = polygon[j].y;
24
- if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
25
- c = !c;
26
- }
27
- }
28
- return c;
35
+ const { x, y } = point;
36
+ let c = false;
37
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
38
+ const xi = polygon[i].x;
39
+ const yi = polygon[i].y;
40
+ const xj = polygon[j].x;
41
+ const yj = polygon[j].y;
42
+ if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) c = !c;
43
+ }
44
+ return c;
29
45
  }
30
46
  function createPolygonElement() {
31
- const id = "debug-polygon";
32
- const existingPolygon = document.getElementById(id);
33
- if (existingPolygon) {
34
- return existingPolygon;
35
- }
36
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
37
- Object.assign(svg.style, {
38
- top: "0",
39
- left: "0",
40
- width: "100%",
41
- height: "100%",
42
- opacity: "0.15",
43
- position: "fixed",
44
- pointerEvents: "none",
45
- fill: "red"
46
- });
47
- const polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
48
- polygon.setAttribute("id", id);
49
- polygon.setAttribute("points", "0,0 0,0");
50
- svg.appendChild(polygon);
51
- document.body.appendChild(svg);
52
- return polygon;
47
+ const id = "debug-polygon";
48
+ const existingPolygon = document.getElementById(id);
49
+ if (existingPolygon) return existingPolygon;
50
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
51
+ Object.assign(svg.style, {
52
+ top: "0",
53
+ left: "0",
54
+ width: "100%",
55
+ height: "100%",
56
+ opacity: "0.15",
57
+ position: "fixed",
58
+ pointerEvents: "none",
59
+ fill: "red"
60
+ });
61
+ const polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
62
+ polygon.setAttribute("id", id);
63
+ polygon.setAttribute("points", "0,0 0,0");
64
+ svg.appendChild(polygon);
65
+ document.body.appendChild(svg);
66
+ return polygon;
53
67
  }
54
68
  function debugPolygon(polygon) {
55
- const el = createPolygonElement();
56
- const points = polygon.map((point) => `${point.x},${point.y}`).join(" ");
57
- el.setAttribute("points", points);
58
- return () => {
59
- el.remove();
60
- };
69
+ const el = createPolygonElement();
70
+ const points = polygon.map((point) => `${point.x},${point.y}`).join(" ");
71
+ el.setAttribute("points", points);
72
+ return () => {
73
+ el.remove();
74
+ };
61
75
  }
62
- export {
63
- debugPolygon,
64
- getElementPolygon,
65
- isPointInPolygon
66
- };
76
+ export { debugPolygon, getElementPolygon, isPointInPolygon };
package/dist/rect.d.mts CHANGED
@@ -1,58 +1,55 @@
1
- import { Point, RectInit, Rect, RectEdge } from './types.mjs';
2
-
3
- declare const createPoint: (x: number, y: number) => {
1
+ import { Point, Rect, RectEdge, RectInit } from "./types.mjs";
2
+ export declare const createPoint: (x: number, y: number) => {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export declare const subtractPoints: (a: Point, b: Point | null) => Point;
7
+ export declare const addPoints: (a: Point, b: Point) => {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ export declare function isPoint(v: any): v is Point;
12
+ export declare function createRect(r: RectInit): Rect;
13
+ export declare function isRect(v: any): v is Rect;
14
+ export declare function getRectCenters(v: Rect): {
15
+ top: {
4
16
  x: number;
5
17
  y: number;
6
- };
7
- declare const subtractPoints: (a: Point, b: Point | null) => Point;
8
- declare const addPoints: (a: Point, b: Point) => {
18
+ };
19
+ right: {
9
20
  x: number;
10
21
  y: number;
22
+ };
23
+ bottom: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ left: {
28
+ x: number;
29
+ y: number;
30
+ };
11
31
  };
12
- declare function isPoint(v: any): v is Point;
13
- declare function createRect(r: RectInit): Rect;
14
- declare function isRect(v: any): v is Rect;
15
- declare function getRectCenters(v: Rect): {
16
- top: {
17
- x: number;
18
- y: number;
19
- };
20
- right: {
21
- x: number;
22
- y: number;
23
- };
24
- bottom: {
25
- x: number;
26
- y: number;
27
- };
28
- left: {
29
- x: number;
30
- y: number;
31
- };
32
- };
33
- declare function getRectCorners(v: Rect): {
34
- top: {
35
- x: number;
36
- y: number;
37
- };
38
- right: {
39
- x: number;
40
- y: number;
41
- };
42
- bottom: {
43
- x: number;
44
- y: number;
45
- };
46
- left: {
47
- x: number;
48
- y: number;
49
- };
50
- };
51
- declare function getRectEdges(v: Rect): {
52
- top: RectEdge;
53
- right: RectEdge;
54
- bottom: RectEdge;
55
- left: RectEdge;
32
+ export declare function getRectCorners(v: Rect): {
33
+ top: {
34
+ x: number;
35
+ y: number;
36
+ };
37
+ right: {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ bottom: {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ left: {
46
+ x: number;
47
+ y: number;
48
+ };
56
49
  };
57
-
58
- export { addPoints, createPoint, createRect, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, subtractPoints };
50
+ export declare function getRectEdges(v: Rect): {
51
+ top: RectEdge;
52
+ right: RectEdge;
53
+ bottom: RectEdge;
54
+ left: RectEdge;
55
+ };