graphic-pixi/lib/plugins/GraphicEditPlugin.d.ts

83 lines
3.3 KiB
TypeScript
Raw Normal View History

2023-12-12 17:31:07 +08:00
import { Container, DisplayObject, Graphics, IDestroyOptions, IPointData } from 'pixi.js';
import { JlGraphic } from '../core';
import { DraggablePoint } from '../graphic';
export declare abstract class GraphicEditPlugin<DO extends DisplayObject = DisplayObject> extends Container {
graphic: DO;
constructor(g: DO);
destroy(options?: boolean | IDestroyOptions | undefined): void;
abstract updateEditedPointsPosition(): void;
hideAll(): void;
showAll(): void;
}
export interface ILineGraphic extends JlGraphic {
get linePoints(): IPointData[];
set linePoints(points: IPointData[]);
}
export declare abstract class LineEditPlugin extends GraphicEditPlugin<ILineGraphic> {
linePoints: IPointData[];
editedPoints: DraggablePoint[];
constructor(g: ILineGraphic);
destroy(options?: boolean | IDestroyOptions | undefined): void;
reset(): void;
abstract initEditPoints(): void;
}
export declare function getWayLineIndex(points: IPointData[], p: IPointData): {
start: number;
end: number;
};
export declare function getWaypointRangeIndex(points: IPointData[], curve: boolean, p: IPointData, lineWidth: number): {
start: number;
end: number;
};
export type onEditPointCreate = (g: ILineGraphic, dp: DraggablePoint, index: number) => void;
export interface IEditPointOptions {
/**
*
*/
onEditPointCreate?: onEditPointCreate;
}
/**
* 线(线)
*/
export declare class PolylineEditPlugin extends LineEditPlugin {
static Name: string;
options: IEditPointOptions;
constructor(g: ILineGraphic, options?: IEditPointOptions);
initEditPoints(): void;
updateEditedPointsPosition(): void;
}
export interface BezierCurveEditPointOptions extends IEditPointOptions {
auxiliaryLineColor?: string;
smooth?: boolean;
symmetry?: boolean;
}
export interface ICompleteBezierCurveEditPointOptions extends BezierCurveEditPointOptions {
smooth: boolean;
}
export declare function addWayPoint(graphic: ILineGraphic, curve: boolean, start: number, end: number, p: IPointData): void;
export declare function addLineWayPoint(graphic: ILineGraphic, start: number, end: number, p: IPointData): void;
export declare function addPolygonSegmentingPoint(graphic: ILineGraphic, start: number, end: number, knife?: number): void;
export declare function addBezierWayPoint(graphic: ILineGraphic, start: number, end: number, p: IPointData): void;
export declare function removeWayPoint(graphic: ILineGraphic, curve: boolean, i: number): void;
export declare function removeLineWayPoint(graphic: ILineGraphic, i: number): void;
export declare function removeBezierWayPoint(graphic: ILineGraphic, i: number): void;
/**
* (),线线
* @param graphic
* @param curve
*/
export declare function clearWayPoint(graphic: ILineGraphic, curve: boolean): void;
/**
* 线
*/
export declare class BezierCurveEditPlugin extends LineEditPlugin {
static Name: string;
options: ICompleteBezierCurveEditPointOptions;
auxiliaryLines: Graphics[];
constructor(g: ILineGraphic, options?: BezierCurveEditPointOptions);
reset(): void;
initEditPoints(): void;
drawAuxiliaryLine(line: Graphics, p1: IPointData, p2: IPointData): void;
updateEditedPointsPosition(): void;
}