graphic-pixi/lib/utils/GraphicUtils.d.ts

233 lines
7.2 KiB
TypeScript
Raw Permalink Normal View History

2023-12-12 17:31:07 +08:00
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)
* 5sideLength和这侧端点到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[];