114 lines
5.0 KiB
TypeScript
114 lines
5.0 KiB
TypeScript
|
declare namespace GlobalMixins {
|
||
|
type JlCanvasType = import('./app').JlCanvas;
|
||
|
type CanvasProperties = import('./app').ICanvasProperties;
|
||
|
type GraphicApp = import('./app').GraphicApp;
|
||
|
type JlGraphicType = import('./core').JlGraphic;
|
||
|
type GraphicData = import('./core').GraphicData;
|
||
|
type GraphicState = import('./core').GraphicState;
|
||
|
type GraphicTransform = import('./core').GraphicTransform;
|
||
|
type AppDragEventType = import('./plugins').GraphicDragEvent;
|
||
|
type BoundsGraphic = import('./graphic').BoundsGraphic;
|
||
|
type IPointDataType = import('pixi.js').IPointData;
|
||
|
type PointType = import('pixi.js').Point;
|
||
|
type DisplayObjectType = import('pixi.js').DisplayObject;
|
||
|
type ContainerType = import('pixi.js').Container;
|
||
|
interface DisplayObjectEvents {
|
||
|
canvassizechange: [JlCanvasType];
|
||
|
'enter-absorbable-area': [number | undefined, number | undefined];
|
||
|
'out-absorbable-area': [number | undefined, number | undefined];
|
||
|
transforming: [JlCanvasType];
|
||
|
dataupdate: [JlGraphicType, GraphicData, GraphicData | undefined];
|
||
|
pointupdate: [obj: DisplayObjectType, points: IPointDataType[]];
|
||
|
stateupdate: [JlGraphicType, GraphicState, GraphicState | undefined];
|
||
|
repaint: [DisplayObjectType];
|
||
|
propertiesupdate: [JlGraphicType | JlCanvasType];
|
||
|
dragstart: [AppDragEventType];
|
||
|
dragmove: [AppDragEventType];
|
||
|
dragend: [AppDragEventType];
|
||
|
scalestart: [DisplayObjectType];
|
||
|
scalemove: [DisplayObjectType];
|
||
|
scaleend: [DisplayObjectType];
|
||
|
rotatestart: [DisplayObjectType];
|
||
|
rotatemove: [DisplayObjectType];
|
||
|
rotateend: [DisplayObjectType];
|
||
|
transformstart: [DisplayObjectType];
|
||
|
transformend: [DisplayObjectType];
|
||
|
selected: [DisplayObjectType];
|
||
|
unselected: [DisplayObjectType];
|
||
|
childselected: [DisplayObjectType];
|
||
|
childunselected: [DisplayObjectType];
|
||
|
}
|
||
|
|
||
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||
|
interface GraphicAppEvents {
|
||
|
propertiesupdate: [selectedData: GraphicData | CanvasProperties | null];
|
||
|
}
|
||
|
|
||
|
interface DisplayObject {
|
||
|
_selectable: boolean;
|
||
|
_selected: boolean;
|
||
|
selectable: boolean; //是否可选中
|
||
|
selected: boolean; // 是否选中
|
||
|
_childEdit: boolean; // 子元素编辑模式
|
||
|
childEdit: boolean;
|
||
|
_transformSave: boolean; // 变换是否保存
|
||
|
transformSave: boolean; //
|
||
|
_assistantAppendMap: Map<string, DisplayObjectType> | null; // 辅助附加图形map
|
||
|
assistantAppendMap: Map<string, DisplayObjectType>;
|
||
|
_draggable: boolean; // 是否可拖拽
|
||
|
draggable: boolean;
|
||
|
_dragStartPoint: PointType | null; // 拖拽起始坐标
|
||
|
dragStartPoint: PointType | null;
|
||
|
_scalable: boolean; // 是否可缩放
|
||
|
scalable: boolean;
|
||
|
_keepAspectRatio: boolean; // 缩放是否保持纵横比,默认保持
|
||
|
keepAspectRatio: boolean;
|
||
|
_rotatable: boolean; // 是否可旋转
|
||
|
rotatable: boolean;
|
||
|
worldAngle: number; // 世界角度,(-180, 180]
|
||
|
getAllParentScaled(): PointType;
|
||
|
saveTransform(): GraphicTransform; // 保存变换
|
||
|
loadTransform(transform: GraphicTransform): void; // 加载变换
|
||
|
isChild(obj: DisplayObject): boolean; // 是否子元素
|
||
|
isParent(obj: DisplayObject): boolean; // 是否父元素
|
||
|
isAssistantAppend(): boolean; // 是否辅助附加图形
|
||
|
addAssistantAppend<D extends DisplayObjectType>(...appends: D[]): void;
|
||
|
removeAssistantAppend(...appends: DisplayObjectType[]): void;
|
||
|
removeAssistantAppendByName(...names: string[]): void;
|
||
|
removeAllAssistantAppend(): void;
|
||
|
getAssistantAppend<D extends DisplayObjectType>(
|
||
|
name: string
|
||
|
): D | undefined; // 获取辅助附加图形对象
|
||
|
isGraphic(): boolean; // 是否业务图形对象
|
||
|
getGraphic<G extends JlGraphicType>(): G | null; // 获取所属的图形对象
|
||
|
isGraphicChild(): boolean; // 是否图形子元素
|
||
|
onAddToCanvas(): void; // 添加到画布处理
|
||
|
onRemoveFromCanvas(): void; //从画布移除处理
|
||
|
isInCanvas(): boolean; // 是否添加到画布中
|
||
|
getCanvas(): JlCanvasType; // 获取所在画布
|
||
|
getViewport(): Viewport; // 获取视口
|
||
|
getGraphicApp(): GraphicApp; // 获取图形app
|
||
|
localToCanvasPoint(p: IPointData): PointType; // 图形本地坐标转为画布坐标
|
||
|
localToCanvasPoints(...points: IPointData[]): PointType[]; // 批量转换
|
||
|
canvasToLocalPoint(p: IPointData): PointType; // 画布坐标转为图形本地坐标
|
||
|
canvasToLocalPoints(...points: IPointData[]): PointType[]; // 批量转换
|
||
|
|
||
|
localToScreenPoint(p: IPointData): PointType; // 本地坐标转为屏幕坐标
|
||
|
localToScreenPoints(...points: IPointData[]): PointType[]; // 批量
|
||
|
screenToLocalPoint(p: IPointData): PointType; // 屏幕坐标转为本地坐标
|
||
|
screenToLocalPoints(...points: IPointData[]): PointType[]; // 批量
|
||
|
|
||
|
localBoundsToCanvasPoints(): PointType[]; // 本地包围框转为多边形点坐标
|
||
|
}
|
||
|
|
||
|
interface Graphics {
|
||
|
drawBezierCurve(
|
||
|
p1: IPointData,
|
||
|
p2: IPointData,
|
||
|
cp1: IPointData,
|
||
|
cp2: IPointData,
|
||
|
segmentsCount: number
|
||
|
): Graphics;
|
||
|
}
|
||
|
}
|