import { Point2d } from "../utils/primitives/Point2d"; import { EDataType, EPostMessageType, EScaleType, EToolsKey, EventWorkState } from "../enum"; import { BaseNodeMapItem, IMainMessage, IRectType, IUpdateNodeOpt, IWorkerMessage } from "../types"; import { Group } from "spritejs"; import { VNodeManager } from "../vNodeManager"; import { ShapeNodes, ShapeOptions, ShapeOptionsType } from "./utils"; import { TextOptions } from "../../component/textEditor/types"; import { SerializerEraserLines } from "./pencilEraserBitMap"; import type { LocalWorkForFullWorker } from "../worker/fullWorkerLocal"; import type { SubLocalMainThreadImpl } from "../mainThread/subLocalThread"; import type { SnapshotThreadImpl } from "../mainThread/snapshotThread"; import type { SubServiceMainThreadImpl } from "../mainThread/subServiceThread"; import type { WorkThreadEngineForSimpleWorker, WorkThreadEngineForFullWorker, WorkThreadEngineForSubWorker } from "../worker/workerManager"; export interface BaseShapeOptions { isOpacity?: boolean; fontColor?: string; fontBgColor?: string; strokeColor?: string; fillColor?: string; vertex?: string; fragment?: string; syncUnitTime?: number; zIndex?: number; scale?: [number, number]; rotate?: number; thickness?: number; textOpt?: TextOptions; translate?: [number, number]; eraserlines?: SerializerEraserLines; lineCap?: "square" | "round"; lineDash?: [number, number]; } export interface BaseShapeToolProps { workId: string; vNodes?: VNodeManager; toolsOpt: ShapeOptions; fullLayer: Group; drawLayer?: Group; } export type BaseConsumeResultType = { type: EPostMessageType; toolsType?: EToolsKey; opt?: ShapeOptions; workId?: string; dataType?: EDataType; } & Partial; export declare abstract class BaseShapeTool { static SafeBorderPadding: number; protected abstract tmpPoints: Array; abstract readonly toolsType: EToolsKey; abstract readonly canRotate: boolean; abstract readonly scaleType: EScaleType; readonly maxImageWidth: number; readonly maxImageHeight: number; syncUnitTime: number; vNodes?: VNodeManager; protected drawLayer?: Group; protected fullLayer: Group; protected workId: string; protected abstract workOptions: ShapeOptions; isDelete: boolean; constructor(props: BaseShapeToolProps); get baseConsumeResult(): { workId: string; toolsType: EToolsKey; opt: ShapeOptions; }; /** 消费本地数据,返回绘制结果 */ abstract consume(props: { data: IWorkerMessage; isFullWork?: boolean; isSubWorker?: boolean; drawCount?: number; isMainThread?: boolean; isSimpleWorker?: boolean; removeDrawCount?: number; smoothSync?: boolean; }): BaseConsumeResultType; /** 消费本地完整数据,返回绘制结果 */ abstract consumeAll(props: { data?: IWorkerMessage; workerEngine?: LocalWorkForFullWorker | SubLocalMainThreadImpl; }): BaseConsumeResultType; /** 消费服务端数据,返回绘制结果 */ abstract consumeService(props: { isFullWork: boolean; op: number[]; isSimpleWorker?: boolean; replaceId?: string; workState?: EventWorkState; worker?: WorkThreadEngineForSimpleWorker | LocalWorkForFullWorker | WorkThreadEngineForFullWorker | WorkThreadEngineForSubWorker | SubLocalMainThreadImpl | SnapshotThreadImpl | SubServiceMainThreadImpl; }): IRectType | undefined; protected filterSamePoints(points: Point2d[], tolerance?: number): Point2d[]; /** 清除临时数据 */ abstract clearTmpPoints(): void; /** 设置工作id */ setWorkId(id: string): void; getWorkId(): string; /** 获取工作选项配置 */ getWorkOptions(): ShapeOptions; /** 设置工作选项配置 */ setWorkOptions(workOptions: BaseShapeOptions): void; /** 更新服务端同步配置,返回绘制结果 */ updataOptService(opt?: IUpdateNodeOpt): IRectType | undefined; drawEraserlines(props: { group: Group; eraserlines: SerializerEraserLines; pos: [number, number]; layer: Group; }, isDrawEraserlines?: boolean): void; private createVmRenderNode; private getGroupRect; private addEraserlines; private isTransparentRectByCanvas; private createSpriteNode; protected computEraserPoints(points: number[], thickness: number): Point2d[]; private computDot; private computLine; replace(layer: Group, replaceId?: string, newNode?: ShapeNodes): void; removeDrawCountNodes(layer: Group, removeDrawCount: number): void; static updateNodeOpt(param: { node: ShapeNodes; opt: IUpdateNodeOpt; vNodes: VNodeManager; willSerializeData?: boolean; targetNode?: BaseNodeMapItem; }): IRectType | undefined; static getCenterPos(r: IRectType, layer: Group): [number, number]; static getRectFromLayer(layer: Group, name: string): IRectType | undefined; static isWillRefresh(params: { toolsType: EToolsKey; opt: ShapeOptionsType; node: ShapeNodes; updateOpt: IUpdateNodeOpt; vNodes: VNodeManager; willSerializeData?: boolean; }): boolean; } export declare const eraserSizes: readonly (Readonly<{ width: 18; height: 26; }> | Readonly<{ width: 26; height: 34; }> | Readonly<{ width: 34; height: 50; }> | Readonly<{ width: 48; height: 74; }>)[];