@tscircuit/math-utils 0.0.34 → 0.0.35
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/get-bound-from-centered-rect.ts
|
|
2
|
+
var getBoundFromCenteredRect = (params) => {
|
|
3
|
+
const { center, width, height } = params;
|
|
4
|
+
const halfWidth = width / 2;
|
|
5
|
+
const halfHeight = height / 2;
|
|
6
|
+
return {
|
|
7
|
+
minX: center.x - halfWidth,
|
|
8
|
+
maxX: center.x + halfWidth,
|
|
9
|
+
minY: center.y - halfHeight,
|
|
10
|
+
maxY: center.y + halfHeight
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
getBoundFromCenteredRect
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-MIHKSXJY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/get-bound-from-centered-rect.ts"],"sourcesContent":["import type { Bounds, Point } from \"./common\"\n\n/**\n * Calculates the bounds of a rectangle given its center point, width, and height.\n * @param params Object containing center point (x, y), width, and height of the rectangle\n * @returns Bounds object containing minX, minY, maxX, maxY\n */\nexport const getBoundFromCenteredRect = (params: {\n center: Point\n width: number\n height: number\n}): Bounds => {\n const { center, width, height } = params\n const halfWidth = width / 2\n const halfHeight = height / 2\n\n return {\n minX: center.x - halfWidth,\n maxX: center.x + halfWidth,\n minY: center.y - halfHeight,\n maxY: center.y + halfHeight,\n }\n}\n"],"mappings":";AAOO,IAAM,2BAA2B,CAAC,WAI3B;AACZ,QAAM,EAAE,QAAQ,OAAO,OAAO,IAAI;AAClC,QAAM,YAAY,QAAQ;AAC1B,QAAM,aAAa,SAAS;AAE5B,SAAO;AAAA,IACL,MAAM,OAAO,IAAI;AAAA,IACjB,MAAM,OAAO,IAAI;AAAA,IACjB,MAAM,OAAO,IAAI;AAAA,IACjB,MAAM,OAAO,IAAI;AAAA,EACnB;AACF;","names":[]}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const halfWidth = width / 2;
|
|
5
|
-
const halfHeight = height / 2;
|
|
6
|
-
return {
|
|
7
|
-
minX: center.x - halfWidth,
|
|
8
|
-
maxX: center.x + halfWidth,
|
|
9
|
-
minY: center.y - halfHeight,
|
|
10
|
-
maxY: center.y + halfHeight
|
|
11
|
-
};
|
|
12
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
getBoundFromCenteredRect
|
|
3
|
+
} from "./chunk-MIHKSXJY.js";
|
|
13
4
|
export {
|
|
14
5
|
getBoundFromCenteredRect
|
|
15
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { Polygon, areBoundsCompletelyInsidePolygon, areBoundsOverlappingPolygon,
|
|
|
15
15
|
export { normalizeDegrees } from './normalize-degrees.js';
|
|
16
16
|
export { getBoundsFromPoints } from './get-bounds-from-points.js';
|
|
17
17
|
export { getBoundsCenter } from './get-bounds-center.js';
|
|
18
|
+
export { getBoundFromCenteredRect } from './get-bound-from-centered-rect.js';
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,9 @@ import {
|
|
|
64
64
|
doBoundsOverlap
|
|
65
65
|
} from "./chunk-CA5ORSO4.js";
|
|
66
66
|
import "./chunk-GYQ2KZV6.js";
|
|
67
|
+
import {
|
|
68
|
+
getBoundFromCenteredRect
|
|
69
|
+
} from "./chunk-MIHKSXJY.js";
|
|
67
70
|
import {
|
|
68
71
|
getBoundsCenter
|
|
69
72
|
} from "./chunk-3WCUPG5S.js";
|
|
@@ -87,6 +90,7 @@ export {
|
|
|
87
90
|
doesLineIntersectLine,
|
|
88
91
|
doesSegmentIntersectRect,
|
|
89
92
|
findNearestPointsBetweenBoxSets,
|
|
93
|
+
getBoundFromCenteredRect,
|
|
90
94
|
getBoundingBox,
|
|
91
95
|
getBoundsCenter,
|
|
92
96
|
getBoundsFromPoints,
|