You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
6.2 KiB

4 months ago
import { AABB } from '@antv/g';
import type { Node, Padding, Point, TriangleDirection } from '../types';
/**
* <zh/>
*
* <en/> Retrieves the width of a bounding box
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> | <en/> Width of box
*/
export declare function getBBoxWidth(bbox: AABB): number;
/**
* <zh/>
*
* <en/> Retrieve the height of a bounding box
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> | <en/> Height of box
*/
export declare function getBBoxHeight(bbox: AABB): number;
/**
* <zh/>
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> | <en/> Size of box
*/
export declare function getBBoxSize(bbox: AABB): [number, number];
/**
* <zh/>
*
* <en/> Get the bounding box of the node, compatible with the case where the node is a point
* @param node - <zh/> | <en/> node or point
* @param padding - <zh/> | <en/> padding
* @returns <zh/> | <en/> bounding box
*/
export declare function getNodeBBox(node: Point | Node, padding?: Padding): AABB;
/**
* <zh/>
*
* <en/> Get the bounding box of a single point
* @param point - <zh/> | <en/> Point
* @returns <zh/> | <en/> Bounding box
*/
export declare function getPointBBox(point: Point): AABB;
/**
* <zh/>
*
* <en/> Get the expanded bounding box
* @param bbox - <zh/> | <en/> Bounding box
* @param padding - <zh/> | <en/> Padding
* @returns <zh/> | <en/> The expanded bounding box
*/
export declare function getExpandedBBox(bbox: AABB, padding: Padding): AABB;
/**
* <zh/>
*
* <en/> Calculate the overall bounding box
* @param bboxes - <zh/> | <en/> List of bounding boxes
* @returns <zh/> | <en/> Overall bounding box
*/
export declare function getCombinedBBox(bboxes: AABB[]): AABB;
/**
* <zh/> bbox1 bbox2
*
* <en/> Determine whether bbox1 is completely contained in bbox2
* @param bbox1 - <zh/> | <en/> Target bounding box
* @param bbox2 - <zh/> | <en/> Reference bounding box
* @returns <zh/> bbox1 bbox2 true false | <en/> Returns true if bbox1 is completely contained in bbox2, false otherwise
*/
export declare function isBBoxInside(bbox1: AABB, bbox2: AABB): boolean;
/**
* <zh/>
*
* <en/> Whether the point is contained in the given box
* @param point - <zh/> | <en/> Point
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> true false | <en/> Returns true if the point is inside the bounding box, false otherwise
*/
export declare function isPointInBBox(point: Point, bbox: AABB): boolean;
/**
* <zh/> 线
*
* <en/> Whether the point is on the boundary or extension line of the given box
* @param point - <zh/> | <en/> Point
* @param bbox - <zh/> | <en/> Bounding box
* @param extended - <zh/> 线 | <en/> Whether to judge the extension line of the boundary
* @returns <zh/> 线 true false | <en/> Returns true if the point is on the boundary or extension line of the bounding box, false otherwise
*/
export declare function isPointOnBBoxBoundary(point: Point, bbox: AABB, extended?: boolean): boolean;
/**
* <zh/>
*
* <en/> Whether the point is outside the given box
* @param point - <zh/> | <en/> Point
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> true false | <en/> Returns true if the point is outside the bounding box, false otherwise
*/
export declare function isPointOutsideBBox(point: Point, bbox: AABB): boolean;
/**
* <zh/>
*
* <en/> When the point is at the center of the bounding box
* @param point - <zh/> | <en/> Point
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> true false | <en/> Returns true if the point is at the center of the bounding box, false otherwise
*/
export declare function isPointBBoxCenter(point: Point, bbox: AABB): boolean;
/**
* <zh/> `p`
*
* <en/> Get a side of the boundary which is nearest to the point `p`
* @param bbox - <zh/> | <en/> Bounding box
* @param p - <zh/> | <en/> Point
* @returns <zh/> `p` | <en/> The side nearest to the point `p`
*/
export declare function getNearestBoundarySide(p: Point, bbox: AABB): 'left' | 'right' | 'top' | 'bottom';
/**
* <zh/> `p`
*
* <en/> Get a point on the boundary nearest to the point `p`
* @param bbox - <zh/> | <en/> Bounding box
* @param p - <zh/> | <en/> Point
* @returns <zh/> `p` | <en/> The point nearest to the point `p`
*/
export declare function getNearestBoundaryPoint(p: Point, bbox: AABB): Point;
/**
* The triangle center point of the bounding box
* @param bbox - bounding box
* @param direction - direction
* @returns Point
*/
export declare function getTriangleCenter(bbox: AABB, direction: TriangleDirection): Point;
/**
* Get incircle radius
* @param bbox - bounding box
* @param direction - direction
* @returns number
*/
export declare function getIncircleRadius(bbox: AABB, direction: TriangleDirection): number;
/**
* <zh/>
*
* <en/> Get the four segments of the bounding box, in order from top, right, bottom, left
* @param bbox - <zh/> | <en/> Bounding box
* @returns <zh/> | <en/> The four segments of the bounding box
*/
export declare function getBBoxSegments(bbox: AABB): [Point, Point][];