import type { ICuboid, ICuboidConfig, IDrawingCuboid } from '@/types/tool/cuboid'; import { IPixelPoints } from '@labelbee/lb-utils'; import { ELineTypes } from '../../constant/tool'; import { IPolygonPoint } from '../../types/tool/polygon'; export interface IDrawTextConfig { color: string; font: string; shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; shadowBlur: number; textMaxWidth: number; offsetX: number; offsetY: number; textAlign: 'start' | 'center' | 'end' | 'left' | 'right'; lineHeight: number; } interface IDrawHighlightFlagParams { canvas: HTMLCanvasElement; color: string; position: { x: number; y: number; }; scale?: number; } export default class DrawUtils { static drawImg: (canvas: HTMLCanvasElement, imgNode: HTMLImageElement | HTMLCanvasElement, options?: Partial) => void; static drawLine(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{ color: string; thickness: number; lineCap: CanvasLineCap; lineDash: number[]; }>): void; /** * 查看绘制拉框 * @param canvas * @param rect * @param options */ static drawRect(canvas: HTMLCanvasElement, rect: IRect, options?: Partial<{ color: string; thickness: number; lineCap: CanvasLineCap; hiddenText: boolean; lineDash: number[]; }>): void; /** * 填充矩形框的绘制 * @param canvas * @param rect * @param options */ static drawRectWithFill(canvas: HTMLCanvasElement, rect: IRect, options?: Partial<{ color: string; }>): void; /** * 通过 DOM 形式创建标签 * @param parent * @param text * @param id * @returns */ static drawTagByDom(parent: HTMLElement, text: string, id: string): HTMLDivElement | undefined; static drawTag(canvas: HTMLCanvasElement, tagList: { keyName: string; value: string[]; }[]): HTMLDivElement | undefined; /** * 绘制点击线条 * @param canvas * @param pointList * @param options * @returns */ static drawLineWithPointList(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{ color: string; thickness: number; lineCap: CanvasLineCap; lineType: ELineTypes; lineDash: number[]; hoverEdgeIndex: number; }>): IPolygonPoint[] | undefined; static drawCircle(canvas: HTMLCanvasElement, anchorPoint: IPoint, radius: number, options?: Partial<{ startAngleDeg: number; endAngleDeg: number; thickness: number; color: string; fill: string; }>): void; static drawCircleWithFill(canvas: HTMLCanvasElement, anchorPoint: IPoint, radius?: number, options?: Partial<{ color: string; }>): void; /** * 绘制特殊点 - 三角形 * * @export * @param {CanvasRenderingContext2D} ctx * @param {ICoord} point * @param {number} [pointRadius=6] * @param {string} fillStyle * @param {boolean} [specialPoint] */ static drawSpecialPoint(canvas: HTMLCanvasElement, point: ICoordinate, pointRadius: number | undefined, fillStyle: string): void; static drawPolygon(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{ color: string; thickness: number; lineCap: CanvasLineCap; isClose: boolean; lineType: ELineTypes; lineDash: number[]; }>): IPolygonPoint[]; static drawPolygonWithFill(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{ color: string; lineType: ELineTypes; }>): IPolygonPoint[] | undefined; static drawPolygonWithFillAndLine(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{ strokeColor: string; fillColor: string; pointColor: string; thickness: number; lineCap: CanvasLineCap; isClose: boolean; lineType: ELineTypes; }>): IPolygonPoint[]; /** * 绘制多边形带有关键点的多边形 * @param canvas * @param pointList * @param options * @returns */ static drawPolygonWithKeyPoint(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{ strokeColor: string; fillColor: string; pointColor: string; thickness: number; lineCap: CanvasLineCap; isClose: boolean; lineType: ELineTypes; isFill: boolean; }>): IPolygonPoint[]; static drawSelectedPolygonWithFillAndLine(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{ strokeColor: string; fillColor: string; pointColor: string; thickness: number; lineCap: CanvasLineCap; isClose: boolean; lineType: ELineTypes; }>): IPolygonPoint[]; static drawText(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, text: string, options?: Partial): void; static wrapText(canvas: HTMLCanvasElement, text: string, x: number, y: number, maxWidth?: number, lineHeight?: number): void; /** * 绘制箭头 * @param ctx * @param startPoint * @param endPoint * @param options */ static drawArrow(ctx: CanvasRenderingContext2D, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{ color: string; thickness: number; lineCap: CanvasLineCap; theta: number; headLen: number; }>): void; static drawArrowByCanvas(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{ color: string; thickness: number; lineCap: CanvasLineCap; theta: number; headLen: number; }>): void; /** * Expansion of other base draw. * * Simple Version. * @param param0 */ static drawCuboid(canvas: HTMLCanvasElement, cuboid: ICuboid | IDrawingCuboid, options?: Partial<{ strokeColor: string; fillColor: string; thickness: number; }>): void; /** * Draw Cuboid and Text in header & bottom. * @param canvas * @param cuboid * @param options * @param dataConfig */ static drawCuboidWithText(canvas: HTMLCanvasElement, cuboid: ICuboid | IDrawingCuboid, options: { strokeColor: string; fillColor?: string; thickness?: number; }, dataConfig: { config: ICuboidConfig; hiddenText?: boolean; selectedID?: string; headerText?: string; bottomText?: string; }): void; /** * Draw by points * * points.length === 100,000++. * @param param0 * @returns */ static drawPixel({ canvas, points, size, defaultRGBA, pixelSize, }: { canvas: HTMLCanvasElement; points: IPixelPoints[]; size: ISize; defaultRGBA?: string; pixelSize?: number; }): { canvas: HTMLCanvasElement; }; /** * Draws a highlight flag. * @param {IDrawHighlightFlagParams} params - The parameters for drawing the highlight flag. * @param {Canvas} params.canvas - The canvas on which to draw the highlight flag. * @param {Object} params.position - The position at which to draw the highlight flag. * @param {string} params.color - The color of the highlight flag. * @param {number} [params.scale=0.1] - The scale of the highlight flag. */ static drawHighlightFlag(params: IDrawHighlightFlagParams): void; } export {};