@zag-js/rect-utils 0.77.1 → 0.78.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/index.d.mts CHANGED
@@ -90,6 +90,8 @@ declare class AffineTransform {
90
90
 
91
91
  declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
92
92
 
93
+ declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
94
+
93
95
  declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
94
96
  x: number;
95
97
  y: number;
@@ -251,4 +253,4 @@ declare function resizeRect(rect: Rect, offset: Point, direction: CompassDirecti
251
253
 
252
254
  declare function union(...rs: Rect[]): Rect;
253
255
 
254
- export { AffineTransform, type AlignOptions, type Bounds, type CenterPoint, type DistanceValue, type ElementRectOptions, type HAlign, type Point, type Rect, type RectCenter, type RectCenters, type RectCorner, type RectCorners, type RectEdge, type RectEdges, type RectInit, type RectInset, type RectPoint, type RectPoints, type RectSide, type ScalingOptions, type Size, type SymmetricRectInset, type VAlign, type WindowRectOptions, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union };
256
+ export { AffineTransform, type AlignOptions, type Bounds, type CenterPoint, type DistanceValue, type ElementRectOptions, type HAlign, type Point, type Rect, type RectCenter, type RectCenters, type RectCorner, type RectCorners, type RectEdge, type RectEdges, type RectInit, type RectInset, type RectPoint, type RectPoints, type RectSide, type ScalingOptions, type Size, type SymmetricRectInset, type VAlign, type 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
@@ -90,6 +90,8 @@ declare class AffineTransform {
90
90
 
91
91
  declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
92
92
 
93
+ declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
94
+
93
95
  declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
94
96
  x: number;
95
97
  y: number;
@@ -251,4 +253,4 @@ declare function resizeRect(rect: Rect, offset: Point, direction: CompassDirecti
251
253
 
252
254
  declare function union(...rs: Rect[]): Rect;
253
255
 
254
- export { AffineTransform, type AlignOptions, type Bounds, type CenterPoint, type DistanceValue, type ElementRectOptions, type HAlign, type Point, type Rect, type RectCenter, type RectCenters, type RectCorner, type RectCorners, type RectEdge, type RectEdges, type RectInit, type RectInset, type RectPoint, type RectPoints, type RectSide, type ScalingOptions, type Size, type SymmetricRectInset, type VAlign, type WindowRectOptions, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union };
256
+ export { AffineTransform, type AlignOptions, type Bounds, type CenterPoint, type DistanceValue, type ElementRectOptions, type HAlign, type Point, type Rect, type RectCenter, type RectCenters, type RectCorner, type RectCorners, type RectEdge, type RectEdges, type RectInit, type RectInset, type RectPoint, type RectPoints, type RectSide, type ScalingOptions, type Size, type SymmetricRectInset, type VAlign, type 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
@@ -188,6 +188,14 @@ function alignRect(a, ref, options) {
188
188
  return vAlign(hAlign(a, ref, h), ref, v);
189
189
  }
190
190
 
191
+ // src/angle.ts
192
+ function getPointAngle(rect, point, reference = rect.center) {
193
+ const x = point.x - reference.x;
194
+ const y = point.y - reference.y;
195
+ const deg = Math.atan2(x, y) * (180 / Math.PI) + 180;
196
+ return 360 - deg;
197
+ }
198
+
191
199
  // src/clamp.ts
192
200
  var clamp = (value, min3, max2) => Math.min(Math.max(value, min3), max2);
193
201
  var clampPoint = (position, size, boundaryRect) => {
@@ -736,6 +744,7 @@ exports.expand = expand;
736
744
  exports.fromRange = fromRange;
737
745
  exports.getElementPolygon = getElementPolygon;
738
746
  exports.getElementRect = getElementRect;
747
+ exports.getPointAngle = getPointAngle;
739
748
  exports.getRectCenters = getRectCenters;
740
749
  exports.getRectCorners = getRectCorners;
741
750
  exports.getRectEdges = getRectEdges;
package/dist/index.mjs CHANGED
@@ -186,6 +186,14 @@ function alignRect(a, ref, options) {
186
186
  return vAlign(hAlign(a, ref, h), ref, v);
187
187
  }
188
188
 
189
+ // src/angle.ts
190
+ function getPointAngle(rect, point, reference = rect.center) {
191
+ const x = point.x - reference.x;
192
+ const y = point.y - reference.y;
193
+ const deg = Math.atan2(x, y) * (180 / Math.PI) + 180;
194
+ return 360 - deg;
195
+ }
196
+
189
197
  // src/clamp.ts
190
198
  var clamp = (value, min3, max2) => Math.min(Math.max(value, min3), max2);
191
199
  var clampPoint = (position, size, boundaryRect) => {
@@ -710,4 +718,4 @@ function transformRect(rect, transform, normalized = true) {
710
718
  return createRectFromPoints(p1, p2, normalized);
711
719
  }
712
720
 
713
- 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, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union };
721
+ 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/rect-utils",
3
- "version": "0.77.1",
3
+ "version": "0.78.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "js",