import { Container, DisplayObject, IPointData, Point, Rectangle } from 'pixi.js'; /** * 递归父节点执行逻辑 * @param obj * @param handler */ export declare function recursiveParents(obj: DisplayObject, handler: (parent: Container) => void): void; /** * 递归父节点查询父节点对象 * @param obj * @param finder * @returns */ export declare function recursiveFindParent(obj: DisplayObject, finder: (parent: Container) => boolean): Container | null; /** * 递归子节点执行逻辑 * @param container * @param handler */ export declare function recursiveChildren(container: Container, handler: (child: DisplayObject) => void): void; /** * 递归子节点查询子节点对象 */ export declare function recursiveFindChild(container: Container, finder: (child: DisplayObject) => boolean): DisplayObject | null; export interface BezierParam { p1: IPointData; p2: IPointData; cp1: IPointData; cp2: IPointData; } /** * 判断贝塞尔曲线数据是否正确 * @param points */ export declare function assertBezierPoints(points: IPointData[]): void; /** * 转换为贝塞尔曲线参数 * @param points * @returns */ export declare function convertToBezierParams(points: IPointData[]): BezierParam[]; /** * 根据分段数计算贝塞尔曲线所有点坐标 * @param basePoints * @param segmentsCount * @returns */ export declare function calculateBezierPoints(basePoints: IPointData[], segmentsCount: number): Point[]; /** * 根据分段数计算贝塞尔曲线所有点坐标 * @param basePoints * @param segmentsCount * @returns */ export declare function calculateOneBezierPoints(p1: IPointData, p2: IPointData, cp1: IPointData, cp2: IPointData, segmentsCount: number): Point[]; /** * 计算矩形中点 */ export declare function getRectangleCenter(rectangle: Rectangle): Point; /** * 计算两个矩形中心对齐的坐标, PS: 计算的是较大包围框的中心 * @param rect1 * @param rect2 * @returns */ export declare function getCenterOfTwoRectangle(rect1: Rectangle, rect2: Rectangle): Point; /** * 序列化图形变换 * @param obj * @returns */ export declare function serializeTransform(obj: DisplayObject): number[]; /** * 反序列化变换数据到图形对象 * @param obj * @param transform */ export declare function deserializeTransformInto(obj: DisplayObject, transform: number[]): void; /** * 将直线转换为多边形 * @param p1 * @param p2 * @param thick * @returns */ export declare function convertLineToPolygonPoints(p1: IPointData, p2: IPointData, thick: number): IPointData[]; /** * 转换矩形为多边形点坐标 * @param rect 矩形 * @returns */ export declare function convertRectangleToPolygonPoints(rect: Rectangle): IPointData[]; /** * 计算线段中点坐标 * @param p1 * @param p2 * @returns */ export declare function calculateLineMidpoint(p1: IPointData, p2: IPointData): Point; /** * 计算线段细分坐标--线段分成几份 * @param p1 * @param p2 * @param knife * @returns */ export declare function calculateLineSegmentingPoint(p1: IPointData, p2: IPointData, knife: number): IPointData[]; /** * 计算点到直线距离 * @param p1 * @param p2 * @param p */ export declare function calculateDistanceFromPointToLine(p1: IPointData, p2: IPointData, p: IPointData): number; /** * 计算点到直线的垂足坐标 * @param p * @param p1 * @param p2 */ export declare function calculateFootPointFromPointToLine(p1: IPointData, p2: IPointData, p: IPointData): Point; /** * 计算直线与圆的交点 * 1用直线到圆心的距离和半径相比,判断是否和圆有交点; * 2求出圆心在直线上面的垂点; * 3算出直线的单位向量e; * 4求出一侧交点(Intersection)到projectPoint的长度(sideLength); * 5求出sideLength和这侧端点到projectPoint距离的比例(ratio); * 6projectPoint +/- ratio * e = 两侧交点; * @param p0 圆心坐标 * @param radius 圆半径 * @param p1 直线坐标1 * @param p2 直线坐标2 * @returns 交点坐标,可能2/1/0个 */ export declare function calculateIntersectionPointOfCircleAndLine(p0: IPointData, radius: number, p1: IPointData, p2: IPointData): Point[]; /** * 计算圆心与圆心外一点与圆的交点(取圆心到点的向量与圆的交点) * @param p0 圆心坐标 * @param radius 圆半径 * @param p 点坐标 * @returns */ export declare function calculateIntersectionPointOfCircleAndPoint(p0: IPointData, radius: number, p: IPointData): Point; /** * 计算点基于点的镜像点坐标 * @param bp 基准点 * @param p 待镜像的点坐标 * @param distance 镜像点到基准点的距离,默认为p到基准点的距离,即对称 * @returns */ export declare function calculateMirrorPoint(bp: IPointData, p: IPointData, distance?: number): Point; /** * 计算基于给定轴的给定点的镜像点坐标 * @param pa 给定轴线的坐标 * @param pb 给定轴线的坐标 * @param p 待镜像点坐标 * @param distance * @returns */ export declare function calculateMirrorPointBasedOnAxis(pa: IPointData, pb: IPointData, p: IPointData, distance?: number): Point; /** * 计算直线与水平夹角,角度按顺时针,从0开始 * @param p1 * @param p2 * @returns 角度,范围[0, 360) */ export declare function angleToAxisx(p1: IPointData, p2: IPointData): number; /** * 计算两线夹角,pc与pa,pb的夹角,顺时针为正,逆时针为负 * @param pa 交点 * @param pb 锚定 * @param pc * @returns 夹角, [-180, 180] */ export declare function angleOfIncludedAngle(pa: IPointData, pb: IPointData, pc: IPointData): number; /** * 计算两点连线的法向量 * @param point1 * @param point2 * @returns 单位法向量 */ export declare function getNormalVector(point1: IPointData, point2: IPointData): number[]; /** * 点延向量方向移动 * @param point * @param normal 单位向量 * @param length 平移长度 * @returns 移动后的点 */ export declare function movePointAlongNormal(point: IPointData, normal: number[], length: number): Point; /** * 计算两组点各自组成直线的相交点(若两线平行 返回第一组坐标第一个点) * @param line1 两点坐标列表 * @param line2 两点坐标列表 * @returns 相交点 */ export declare function getIntersectionPoint(line1: number[], line2: number[]): Point; /** * 是否平行线 * @param p1 * @param p2 * @param pa * @param pb * @returns */ export declare function isParallelLines(p1: IPointData, p2: IPointData, pa: IPointData, pb: IPointData): boolean; /** * 点是否在线段上 * @param p1 * @param p2 * @param p * @returns */ export declare function isPointOnLine(p1: IPointData, p2: IPointData, p: IPointData): boolean; /** * 两条线段是否存在包含关系 * @param line1 * @param line2 * @returns */ export declare function isLineContainOther(line1: { p1: IPointData; p2: IPointData; }, line2: { p1: IPointData; p2: IPointData; }): boolean; /** 均分线段, 返回各线段端点 */ export declare function splitLineEvenly(p1: IPointData, p2: IPointData, count: number): IPointData[][]; export declare function splitPolyline(points: IPointData[], count: number): IPointData[][]; export declare function getParallelOfPolyline(points: IPointData[], offset: number, side: 'L' | 'R'): IPointData[];