zkqh-canvas-select-one 2.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +288 -0
- package/lib/EventBus.d.ts +21 -0
- package/lib/canvas-select.esm.js +8 -0
- package/lib/canvas-select.esm.js.map +1 -0
- package/lib/canvas-select.min.js +8 -0
- package/lib/canvas-select.min.js.map +1 -0
- package/lib/index.d.ts +438 -0
- package/lib/shape/Brush.d.ts +9 -0
- package/lib/shape/Circle.d.ts +7 -0
- package/lib/shape/Dot.d.ts +5 -0
- package/lib/shape/Ellipse.d.ts +11 -0
- package/lib/shape/Eraser.d.ts +8 -0
- package/lib/shape/Grid.d.ts +12 -0
- package/lib/shape/Line.d.ts +6 -0
- package/lib/shape/Polygon.d.ts +6 -0
- package/lib/shape/Rect.d.ts +12 -0
- package/lib/shape/Shape.d.ts +42 -0
- package/lib/tools.d.ts +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-select.esm.js","sources":["../src/shape/Shape.ts","../src/index.ts","../src/tools.ts","../src/shape/Rect.ts","../src/shape/Polygon.ts","../src/shape/Dot.ts","../src/EventBus.ts","../src/shape/Line.ts","../src/shape/Circle.ts","../src/shape/Grid.ts","../src/shape/Brush.ts","../src/shape/Eraser.ts","../src/shape/Ellipse.ts"],"sourcesContent":["import { createUuid } from \"../tools\"\n\ninterface ShapeProp {\n type: number\n [key: string]: any\n}\nexport default class Shape {\n /** 标签 */\n public label: string = ''\n /** 是否隐藏标签 */\n public hideLabel: boolean | undefined\n /** 坐标 */\n public coor: any[] = []\n /** 边线颜色 */\n public strokeStyle: string | undefined\n /** 填充颜色 */\n public fillStyle: string | undefined\n /** 边线宽度 */\n public lineWidth: number | undefined\n /** 标签填充颜色 */\n public labelFillStyle: string | undefined\n /** 标签文字颜色 */\n public textFillStyle: string | undefined\n /** 标签文字字体 */\n public labelFont: string | undefined\n /** 标注类型 */\n public type: number | undefined\n /** 当前是否处于活动状态 */\n public active: boolean = false\n /** 当前是否处于创建状态 */\n public creating: boolean = false\n /** 当前是否处于拖拽状态 */\n public dragging: boolean = false\n /** 索引 */\n public index: number\n /** 唯一标识 */\n public uuid: string = createUuid()\n /** 向上展示label */\n public labelUp: boolean | undefined\n /** 隐藏标注 */\n public hide: boolean | undefined\n constructor(item: ShapeProp, index: number) {\n this.index = index\n Object.assign(this, item)\n }\n}\n","import Rect from \"./shape/Rect\";\nimport Polygon from \"./shape/Polygon\";\nimport Dot from \"./shape/Dot\";\nimport EventBus from \"./EventBus\";\nimport Line from \"./shape/Line\";\nimport Circle from \"./shape/Circle\";\nimport Grid from \"./shape/Grid\";\nimport pkg from \"../package.json\";\nimport Brush from \"./shape/Brush\";\nimport Eraser from \"./shape/Eraser\";\nimport Ellipse from \"./shape/Ellipse\";\n\nexport type Point = [number, number];\nexport type AllShape =\n | Rect\n | Polygon\n | Dot\n | Line\n | Circle\n | Grid\n | Brush\n | Eraser\n | Ellipse;\nenum Shape {\n None,\n Rect,\n Polygon,\n Dot,\n Line,\n Circle,\n Grid,\n Brush,\n Eraser,\n Ellipse,\n}\nexport default class CanvasSelect extends EventBus {\n /** 当前版本 */\n version = pkg.version;\n /** 只读模式,画布不允许任何交互 */\n lock: boolean = false;\n /** 只读模式,仅支持查看 */\n readonly: boolean = false;\n /** 最小矩形宽度 */\n MIN_WIDTH = 10;\n /** 最小矩形高度 */\n MIN_HEIGHT = 10;\n /** 最小圆形半径 */\n MIN_RADIUS = 5;\n /** 多边形最大点数 */\n MAX_POLYGON_POINTS = 6;\n /** 边线颜色 */\n strokeStyle = \"#0f0\";\n /** 填充颜色 */\n fillStyle = \"rgba(0, 0, 255, 0.1)\";\n /** 边线宽度 */\n lineWidth = 1;\n /** 当前选中的标注边线颜色 */\n activeStrokeStyle = \"#f00\";\n /** 当前选中的标注填充颜色 */\n activeFillStyle = \"rgba(0, 0, 255, 0.1)\";\n /** 控制点边线颜色 */\n ctrlStrokeStyle = \"#000\";\n /** 控制点填充颜色 */\n ctrlFillStyle = \"#fff\";\n /** 控制点半径 */\n ctrlRadius = 3;\n /** 是否隐藏标签 */\n hideLabel = false;\n /** 标签背景填充颜色 */\n labelFillStyle = \"#fff\";\n /** 标签字体 */\n labelFont = \"10px sans-serif\";\n /** 标签文字颜色 */\n textFillStyle = \"#000\";\n /** 标签字符最大长度,超出使用省略号 */\n labelMaxLen = 10;\n /** 画布宽度 */\n WIDTH = 0;\n maxPolygonPoint = 6; // 最大多边形点数\n /** 画布高度 */\n HEIGHT = 0;\n /** XY十字坐标 */\n crossX = new Line({}, 0, {});\n crossY = new Line({}, 1, {});\n crossStroke = \"#ff0\";\n /** 开启十字辅助 */\n showCross = false;\n /** 开启矩形旋转控制点 */\n showRotation = false;\n\n canvas: HTMLCanvasElement | undefined;\n\n ctx: CanvasRenderingContext2D | null | undefined;\n /** 所有标注数据 */\n dataset: AllShape[] = [];\n\n offScreen: HTMLCanvasElement | undefined;\n\n offScreenCtx: CanvasRenderingContext2D | null | undefined;\n\n // 放大镜相关配置 Start\n magnifierCanvas: HTMLCanvasElement | undefined;\n magnifierCtx: CanvasRenderingContext2D | undefined;\n // 默认展示放大镜\n isMagnifierVisible: boolean = false;\n // 放大镜位置,默认跟随鼠标\n magnifierPosition: Point | \"auto\" = \"auto\";\n // 放大镜相关配置 End\n\n /** 记录锚点距离 */\n remmber: number[][] = [];\n /** 记录鼠标位置 */\n mouse: Point = [0, 0];\n /** 记录背景图鼠标位移 */\n remmberOrigin: number[] = [0, 0];\n /** 0 不创建,1 矩形,2 多边形,3 点,4 折线,5 圆,6 网格 */\n createType: Shape = Shape.None; //\n /** 控制点索引 */\n ctrlIndex = -1;\n /** 背景图片 */\n image: HTMLImageElement = new Image();\n /** 图片原始宽度 */\n IMAGE_ORIGIN_WIDTH: number = 0;\n /** 图片缩放宽度 */\n IMAGE_WIDTH = 0;\n /** 图片原始高度 */\n IMAGE_ORIGIN_HEIGHT = 0;\n /** 图片缩放高度 */\n IMAGE_HEIGHT = 0;\n /** 原点x */\n originX = 0;\n /** 原点y */\n originY = 0;\n /** 缩放步长 */\n scaleStep = 0;\n /** 滚动缩放 */\n scrollZoom = true;\n\n private timer: any = null;\n /** 最小touch双击时间 */\n dblTouch = 300;\n /** 记录touch双击开始时间 */\n dblTouchStore = 0; //\n /** 这个选项可以帮助浏览器进行内部优化 */\n alpha = true;\n /** 专注模式 */\n focusMode = false;\n /** 触控缩放时记录上一次两点距离 */\n scaleTouchStore = 0;\n /** 当前是否为双指触控 */\n isTouch2 = false;\n isMobile = navigator.userAgent.includes(\"Mobile\");\n /** 向上展示label */\n labelUp = false;\n private isCtrlKey = false;\n /** 自定义ctrl快捷键 KeyboardEvent.code */\n ctrlCode = \"ControlLeft\";\n /** 网格右键菜单 */\n gridMenuEnable = true;\n /** 网格选中背景填充颜色 */\n gridSelectedFillStyle = \"rgba(255, 255, 0, 0.6)\";\n /** 画笔大小 */\n brushSize = 20;\n /** 画笔颜色 */\n brushStokeStyle = \"#f00\";\n /** 橡皮擦大小 */\n eraserSize = 20;\n /** 标注坐标 (以背景图片左上角为原点) */\n position: number[] = [0, 0];\n /**\n * @param el Valid CSS selector string, or DOM\n * @param src image src\n */\n constructor(el: HTMLCanvasElement | string, src?: string | HTMLImageElement) {\n super();\n this.handleLoad = this.handleLoad.bind(this);\n this.handleContextmenu = this.handleContextmenu.bind(this);\n this.handleMousewheel = this.handleMousewheel.bind(this);\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n this.handleDblclick = this.handleDblclick.bind(this);\n this.handleKeyup = this.handleKeyup.bind(this);\n this.handleKeydown = this.handleKeydown.bind(this);\n const container = typeof el === \"string\" ? document.querySelector(el) : el;\n if (container instanceof HTMLCanvasElement) {\n this.canvas = container;\n this.offScreen = document.createElement(\"canvas\");\n this.initSetting();\n this.initEvents();\n src && this.setImage(src);\n } else {\n console.warn(\"HTMLCanvasElement is required!\");\n }\n this.crossX.strokeStyle = this.crossStroke;\n this.crossY.strokeStyle = this.crossStroke;\n }\n\n /** 当前当前选中的标注 */\n get activeShape() {\n return this.dataset.find((x) => x.active) || ({} as any);\n }\n\n /** 当前缩放比例 */\n get scale() {\n if (this.IMAGE_ORIGIN_WIDTH && this.IMAGE_WIDTH) {\n return this.IMAGE_WIDTH / this.IMAGE_ORIGIN_WIDTH;\n }\n return 1;\n }\n\n /** 图片最小边尺寸 */\n get imageMin() {\n return Math.min(this.IMAGE_WIDTH, this.IMAGE_HEIGHT);\n }\n\n /** 图片原始最大边尺寸 */\n get imageOriginMax() {\n return Math.max(this.IMAGE_ORIGIN_WIDTH, this.IMAGE_ORIGIN_HEIGHT);\n }\n\n /** 创建放大镜容器 */\n createMagnifierCanvas() {\n if (this.isMagnifierVisible) {\n this.magnifierCanvas =\n this.magnifierCanvas || document.createElement(\"canvas\");\n this.magnifierCtx =\n this.magnifierCanvas &&\n (this.magnifierCanvas.getContext(\"2d\", {\n willReadFrequently: true,\n }) as CanvasRenderingContext2D);\n this.magnifierCanvas.style.position = \"fixed\";\n this.magnifierCanvas.style.pointerEvents = \"none\";\n this.magnifierCanvas.style.zIndex = \"1000\";\n this.magnifierCanvas.style.border = \"1px solid black\";\n this.magnifierCanvas.style.borderRadius = \"50%\";\n this.magnifierCanvas.style.width = \"100px\";\n this.magnifierCanvas.style.height = \"100px\";\n document.body.appendChild(this.magnifierCanvas);\n }\n }\n\n /** 创建放大镜 */\n createMagnifier(x: number, y: number) {\n if (!this.magnifierCanvas) {\n this.createMagnifierCanvas();\n } else {\n this.updateMagnifier(x, y);\n }\n }\n /** 更新放大镜 */\n updateMagnifier(x: number, y: number) {\n if (this.canvas && this.magnifierCanvas && this.magnifierCtx) {\n const magnifierSize = 100;\n const dpr = window.devicePixelRatio || 1;\n this.magnifierCanvas.width = magnifierSize;\n this.magnifierCanvas.height = magnifierSize;\n this.magnifierCtx.clearRect(0, 0, magnifierSize, magnifierSize);\n\n // 放大镜位置\n if (this.magnifierPosition && this.magnifierPosition.length === 2) {\n const [mx, my] = this.magnifierPosition;\n this.magnifierCanvas.style.left = `${mx}px`;\n this.magnifierCanvas.style.top = `${my}px`;\n } else {\n this.magnifierCanvas.style.left = `${x + 10}px`;\n this.magnifierCanvas.style.top = `${y + 10}px`;\n }\n\n const originImageData = this.getImageDataFromCanvas(this.canvas, [\n x * dpr - magnifierSize / 2,\n y * dpr - magnifierSize / 2,\n magnifierSize,\n magnifierSize,\n ]);\n // 新的像素信息对象\n const areaImageData = this.magnifierCanvas\n .getContext(\"2d\", { willReadFrequently: true })\n ?.createImageData(\n this.magnifierCanvas.width,\n this.magnifierCanvas.height\n );\n\n if (areaImageData && originImageData) {\n let count = 0;\n for (let j = 0; j < magnifierSize; j += 1) {\n for (let i = 0; i < magnifierSize; i += 1) {\n for (let k = j; k < j + 1; k++) {\n for (let m = i; m < i + 1; m++) {\n const index = (k * magnifierSize + m) * 4;\n areaImageData.data[index] = originImageData.data[count];\n areaImageData.data[index + 1] = originImageData.data[count + 1];\n areaImageData.data[index + 2] = originImageData.data[count + 2];\n areaImageData.data[index + 3] = originImageData.data[count + 3];\n }\n }\n count += 4;\n }\n }\n this.magnifierCanvas\n .getContext(\"2d\", { willReadFrequently: true })\n ?.putImageData(areaImageData, 0, 0);\n\n // 十字线 有需要可以加\n // this.magnifierCtx.strokeStyle = 'rgba(255, 0, 0, 0.7)';\n // this.magnifierCtx.lineWidth = 1;\n // this.magnifierCtx.beginPath();\n // this.magnifierCtx.moveTo(magnifierSize / 2, 0);\n // this.magnifierCtx.lineTo(magnifierSize / 2, magnifierSize);\n // this.magnifierCtx.moveTo(0, magnifierSize / 2);\n // this.magnifierCtx.lineTo(magnifierSize, magnifierSize / 2);\n // this.magnifierCtx.stroke();\n\n // // 绘制放大镜边框\n this.magnifierCtx.strokeStyle = \"rgba(0, 0, 0, 0.5)\";\n this.magnifierCtx.lineWidth = 2;\n this.magnifierCtx.strokeRect(0, 0, magnifierSize, magnifierSize);\n }\n }\n }\n\n /** 销毁放大镜 */\n private destroyMagnifier() {\n if (this.magnifierCanvas) {\n this.magnifierCanvas.remove();\n this.magnifierCanvas = undefined;\n this.magnifierCtx = undefined;\n }\n }\n\n /* 提取像素信息 */\n getImageDataFromCanvas(\n canvas: HTMLCanvasElement,\n [x, y, width, height]: [number, number, number, number]\n ) {\n const context = canvas.getContext(\"2d\", { willReadFrequently: true });\n return context?.getImageData(x, y, width, height);\n }\n\n /** 合成事件 */\n public mergeEvent(e: TouchEvent | MouseEvent) {\n let mouseX = 0;\n let mouseY = 0;\n let mouseCX = 0;\n let mouseCY = 0;\n if (this.isMobile && (e as TouchEvent).touches) {\n const { clientX, clientY } = (e as TouchEvent).touches[0];\n const target = e.target as HTMLCanvasElement;\n const { left, top } = target.getBoundingClientRect();\n mouseX = Math.round(clientX - left);\n mouseY = Math.round(clientY - top);\n if ((e as TouchEvent).touches?.length === 2) {\n const { clientX: clientX1 = 0, clientY: clientY1 = 0 } =\n (e as TouchEvent).touches[1] || {};\n mouseCX = Math.round(\n Math.abs((clientX1 - clientX) / 2 + clientX) - left\n );\n mouseCY = Math.round(\n Math.abs((clientY1 - clientY) / 2 + clientY) - top\n );\n } else if ((e as TouchEvent).touches?.length === 1) {\n mouseCX = Math.round(clientX - left);\n mouseCY = Math.round(clientY - top);\n }\n } else {\n mouseX = (e as MouseEvent).offsetX;\n mouseY = (e as MouseEvent).offsetY;\n }\n return { ...e, mouseX, mouseY, mouseCX, mouseCY };\n }\n\n private handleLoad() {\n this.emit(\"load\", this.image.src);\n this.IMAGE_ORIGIN_WIDTH = this.IMAGE_WIDTH = this.image.width;\n this.IMAGE_ORIGIN_HEIGHT = this.IMAGE_HEIGHT = this.image.height;\n this.fitZoom();\n }\n\n private handleContextmenu(e: MouseEvent) {\n e.preventDefault();\n if (this.lock) return;\n }\n\n private handleMousewheel(e: WheelEvent) {\n e.preventDefault();\n e.stopPropagation();\n if (this.lock || !this.scrollZoom) return;\n const { mouseX, mouseY } = this.mergeEvent(e);\n this.mouse = [mouseX, mouseY];\n this.setScale(e.deltaY < 0, true);\n }\n\n private handleMouseDown(e: MouseEvent | TouchEvent) {\n e.stopPropagation();\n if (this.lock) return;\n const { mouseX, mouseY, mouseCX, mouseCY } = this.mergeEvent(e);\n const offsetX = Math.round(mouseX / this.scale);\n const offsetY = Math.round(mouseY / this.scale);\n this.mouse =\n this.isMobile && (e as TouchEvent).touches?.length === 2\n ? [mouseCX, mouseCY]\n : [mouseX, mouseY];\n this.remmberOrigin = [mouseX - this.originX, mouseY - this.originY];\n if (\n (!this.isMobile && (e as MouseEvent).buttons === 1) ||\n (this.isMobile && (e as TouchEvent).touches?.length === 1)\n ) {\n // 鼠标左键\n const ctrls = this.activeShape.ctrlsData || [];\n this.ctrlIndex = ctrls.findIndex((coor: Point) =>\n this.isPointInCircle(this.mouse, coor, this.ctrlRadius)\n );\n if (this.ctrlIndex > -1 && !this.readonly) {\n // 点击到控制点\n const [x0, y0] = ctrls[this.ctrlIndex];\n if (\n this.activeShape.type === Shape.Polygon &&\n this.activeShape.coor.length > 2 &&\n this.ctrlIndex === 0\n ) {\n this.handleDblclick(e);\n }\n this.remmber = [[offsetX - x0, offsetY - y0]];\n } else if (this.isInBackground(e)) {\n const nx = Math.round(offsetX - this.originX / this.scale);\n const ny = Math.round(offsetY - this.originY / this.scale);\n if (this.activeShape.creating && !this.readonly) {\n // 创建中\n if ([Shape.Polygon, Shape.Line].includes(this.activeShape.type)) {\n const [x, y] =\n this.activeShape.coor[this.activeShape.coor.length - 1];\n if (x !== offsetX && y !== offsetY) {\n this.activeShape.coor.push([nx, ny]);\n\n // 对于多边形,检查是否达到最大点数\n if (\n this.activeShape.type === Shape.Polygon &&\n this.MAX_POLYGON_POINTS &&\n this.activeShape.coor.length >= this.MAX_POLYGON_POINTS\n ) {\n console.log(\"@13131\");\n // 达到最大点数,自动完成绘制\n this.handleDblclick(e);\n }\n\n // 对于折线,检查是否达到2个点\n if (\n this.activeShape.type === Shape.Line &&\n this.activeShape.coor.length >= 2\n ) {\n // 达到2个点,自动完成绘制\n this.handleDblclick(e);\n }\n }\n }\n } else if (\n this.createType !== Shape.None &&\n !this.readonly &&\n !this.isCtrlKey\n ) {\n // 开始创建\n let newShape;\n const curPoint: Point = [nx, ny];\n switch (this.createType) {\n case Shape.Rect:\n newShape = new Rect(\n { coor: [curPoint, curPoint] },\n this.dataset.length,\n this\n );\n newShape.creating = true;\n break;\n case Shape.Polygon:\n newShape = new Polygon(\n { coor: [curPoint] },\n this.dataset.length,\n this\n );\n newShape.creating = true;\n break;\n case Shape.Dot:\n newShape = new Dot({ coor: curPoint }, this.dataset.length, this);\n this.emit(\"add\", newShape);\n break;\n case Shape.Line:\n newShape = new Line(\n { coor: [curPoint] },\n this.dataset.length,\n this\n );\n newShape.creating = true;\n break;\n case Shape.Circle:\n newShape = new Circle(\n { coor: curPoint },\n this.dataset.length,\n this\n );\n console.log(newShape);\n newShape.creating = true;\n break;\n case Shape.Grid:\n newShape = new Grid(\n { coor: [curPoint, curPoint] },\n this.dataset.length,\n this\n );\n newShape.creating = true;\n break;\n case Shape.Brush:\n newShape = new Brush(\n { coor: [curPoint] },\n this.dataset.length,\n this\n );\n newShape.creating = true;\n break;\n case Shape.Eraser:\n newShape = new Eraser(\n { coor: [curPoint] },\n this.dataset.length,\n this\n );\n newShape.creating = true;\n break;\n default:\n break;\n }\n if (newShape) {\n this.dataset.forEach((sp) => {\n sp.active = false;\n });\n newShape.active = true;\n this.dataset.push(newShape);\n }\n } else {\n // 是否点击到形状\n const [hitShapeIndex, hitShape] = this.hitOnShape(this.mouse);\n if (hitShapeIndex > -1 && hitShape) {\n hitShape.dragging = true;\n this.dataset.forEach(\n (item, i) => (item.active = i === hitShapeIndex)\n );\n this.dataset.splice(hitShapeIndex, 1);\n this.dataset.push(hitShape);\n if (!this.readonly) {\n this.remmber = [];\n if ([Shape.Dot, Shape.Circle].includes(hitShape.type)) {\n const [x, y] = hitShape.coor;\n this.remmber = [[offsetX - x, offsetY - y]];\n } else {\n hitShape.coor.forEach((pt: any) => {\n this.remmber.push([offsetX - pt[0], offsetY - pt[1]]);\n });\n }\n }\n this.emit(\"select\", hitShape);\n } else {\n this.activeShape.active = false;\n this.dataset.sort((a, b) => a.index - b.index);\n this.emit(\"select\", null);\n }\n }\n this.update();\n }\n } else if (\n (!this.isMobile && (e as MouseEvent).buttons === 2) ||\n (this.isMobile &&\n (e as TouchEvent).touches?.length === 3 &&\n !this.readonly)\n ) {\n // 鼠标右键\n if ([Shape.Grid].includes(this.activeShape.type) && this.gridMenuEnable) {\n const rowCol = prompt(\n \"x 行 y 列 x,y\",\n [this.activeShape.row, this.activeShape.col].join(\",\")\n );\n if (typeof rowCol === \"string\") {\n const [row, col] = rowCol.split(\",\");\n if (/^[1-9]\\d*$/.test(row) && /^[1-9]\\d*$/.test(col)) {\n this.activeShape.row = Number(row);\n this.activeShape.col = Number(col);\n this.update();\n }\n }\n }\n this.emit(\"contextmenu\", e);\n }\n }\n\n private handleMouseMove(e: MouseEvent | TouchEvent) {\n e.stopPropagation();\n if (this.lock) return;\n const { mouseX, mouseY, mouseCX, mouseCY } = this.mergeEvent(e);\n const offsetX = Math.round(mouseX / this.scale);\n const offsetY = Math.round(mouseY / this.scale);\n if (!this.isCtrlKey && this.isInBackground(e)) {\n this.crossX.coor = [\n [offsetX - this.originX / this.scale, 0],\n [offsetX - this.originX / this.scale, this.image.height],\n ];\n this.crossY.coor = [\n [0, offsetY - this.originY / this.scale],\n [this.image.width, offsetY - this.originY / this.scale],\n ];\n } else {\n this.crossX.coor = [];\n this.crossY.coor = [];\n }\n this.mouse =\n this.isMobile && (e as TouchEvent).touches?.length === 2\n ? [mouseCX, mouseCY]\n : [mouseX, mouseY];\n const nx = Math.round(offsetX - this.originX / this.scale);\n const ny = Math.round(offsetY - this.originY / this.scale);\n this.position = [nx, ny];\n if (\n ((!this.isMobile && (e as MouseEvent).buttons === 1) ||\n (this.isMobile && (e as TouchEvent).touches?.length === 1)) &&\n this.activeShape.type\n ) {\n if (\n this.ctrlIndex > -1 &&\n this.remmber.length &&\n (this.isInBackground(e) || this.activeShape.type === Shape.Circle)\n ) {\n const [[x, y]] = this.remmber;\n // resize矩形或旋转\n if ([Shape.Rect, Shape.Grid].includes(this.activeShape.type)) {\n // 处理旋转控制点(索引8)\n if (this.ctrlIndex === 8) {\n const [centerX, centerY] = this.activeShape.center;\n const mouseX = offsetX - x;\n const mouseY = offsetY - y;\n const dx = mouseX - centerX;\n const dy = mouseY - centerY;\n this.activeShape.rotation = Math.atan2(dy, dx) + Math.PI / 2;\n } else {\n // 处理resize控制点\n const [[x0, y0], [x1, y1]] = this.activeShape.coor;\n let coor: Point[] = [];\n switch (this.ctrlIndex) {\n case 0:\n coor = [\n [offsetX - x, offsetY - y],\n [x1, y1],\n ];\n break;\n case 1:\n coor = [\n [x0, offsetY - y],\n [x1, y1],\n ];\n break;\n case 2:\n coor = [\n [x0, offsetY - y],\n [offsetX - x, y1],\n ];\n break;\n case 3:\n coor = [\n [x0, y0],\n [offsetX - x, y1],\n ];\n break;\n case 4:\n coor = [\n [x0, y0],\n [offsetX - x, offsetY - y],\n ];\n break;\n case 5:\n coor = [\n [x0, y0],\n [x1, offsetY - y],\n ];\n break;\n case 6:\n coor = [\n [offsetX - x, y0],\n [x1, offsetY - y],\n ];\n break;\n case 7:\n coor = [\n [offsetX - x, y0],\n [x1, y1],\n ];\n break;\n default:\n break;\n }\n let [[a0, b0], [a1, b1]] = coor;\n if (\n a0 < 0 ||\n a1 < 0 ||\n b0 < 0 ||\n b1 < 0 ||\n a1 > this.IMAGE_ORIGIN_WIDTH ||\n b1 > this.IMAGE_ORIGIN_HEIGHT\n ) {\n // 偶然触发 超出边界处理\n a0 < 0 && (a0 = 0);\n a1 < 0 && (a1 = 0);\n b0 < 0 && (b0 = 0);\n b1 < 0 && (b1 = 0);\n if (a1 > this.IMAGE_ORIGIN_WIDTH) {\n a1 = this.IMAGE_ORIGIN_WIDTH;\n }\n if (b1 > this.IMAGE_ORIGIN_HEIGHT) {\n b1 = this.IMAGE_ORIGIN_HEIGHT;\n }\n }\n\n if (a1 - a0 >= this.MIN_WIDTH && b1 - b0 >= this.MIN_HEIGHT) {\n this.activeShape.coor = [\n [a0, b0],\n [a1, b1],\n ];\n } else {\n this.emit(\n \"warn\",\n `Width cannot be less than ${this.MIN_WIDTH},Height cannot be less than${this.MIN_HEIGHT}。`\n );\n }\n }\n } else if (\n [Shape.Polygon, Shape.Line].includes(this.activeShape.type)\n ) {\n const newPoint = [nx, ny];\n this.activeShape.coor.splice(this.ctrlIndex, 1, newPoint);\n } else if (this.activeShape.type === Shape.Circle) {\n const nx = Math.round(offsetX - this.originX / this.scale);\n const newRadius = nx - this.activeShape.coor[0];\n if (newRadius >= this.MIN_RADIUS) this.activeShape.radius = newRadius;\n }\n if (this.isMagnifierVisible) {\n const [ux, uy] = this.isMobile\n ? [mouseCX, mouseCY]\n : [mouseX, mouseY];\n this.createMagnifier(ux, uy);\n }\n } else if (this.activeShape.dragging && !this.readonly) {\n // 拖拽\n // 拖拽点的时候,也需要触发放大镜\n if (this.isMagnifierVisible && this.activeShape.type === 3) {\n const [ux, uy] = this.isMobile\n ? [mouseCX, mouseCY]\n : [mouseX, mouseY];\n this.createMagnifier(ux, uy);\n }\n let coor = [];\n let noLimit = true;\n const w = this.IMAGE_ORIGIN_WIDTH || this.WIDTH;\n const h = this.IMAGE_ORIGIN_HEIGHT || this.HEIGHT;\n if ([Shape.Dot, Shape.Circle].includes(this.activeShape.type)) {\n const [t1, t2] = this.remmber[0];\n const x = offsetX - t1;\n const y = offsetY - t2;\n if (x < 0 || x > w || y < 0 || y > h) noLimit = false;\n coor = [x, y];\n } else {\n for (let i = 0; i < this.activeShape.coor.length; i++) {\n const tar = this.remmber[i];\n const x = offsetX - tar[0];\n const y = offsetY - tar[1];\n if (x < 0 || x > w || y < 0 || y > h) noLimit = false;\n coor.push([x, y]);\n }\n }\n if (noLimit) this.activeShape.coor = coor;\n } else if (this.activeShape.creating && this.isInBackground(e)) {\n // const x = Math.round(offsetX - this.originX / this.scale);\n // const y = Math.round(offsetY - this.originY / this.scale);\n // 创建矩形\n if ([Shape.Rect, Shape.Grid].includes(this.activeShape.type)) {\n this.activeShape.coor.splice(1, 1, [nx, ny]);\n } else if (this.activeShape.type === Shape.Circle) {\n const [x0, y0] = this.activeShape.coor;\n const r = Math.sqrt((x0 - nx) ** 2 + (y0 - ny) ** 2);\n this.activeShape.radius = r;\n } else if (\n [Shape.Brush, Shape.Eraser].includes(this.activeShape.type)\n ) {\n this.activeShape.coor.push([nx, ny]);\n }\n }\n this.update();\n } else if (\n [Shape.Polygon, Shape.Line].includes(this.activeShape.type) &&\n this.activeShape.creating\n ) {\n // 多边形添加点\n this.update();\n } else if (\n (!this.isMobile &&\n (e as MouseEvent).buttons === 2 &&\n (e as MouseEvent).which === 3) ||\n (this.isMobile &&\n (e as TouchEvent).touches?.length === 1 &&\n !this.isTouch2)\n ) {\n // 拖动背景\n this.originX = Math.round(mouseX - this.remmberOrigin[0]);\n this.originY = Math.round(mouseY - this.remmberOrigin[1]);\n this.update();\n } else if (this.isMobile && (e as TouchEvent).touches?.length === 2) {\n this.isTouch2 = true;\n const touch0 = (e as TouchEvent).touches[0];\n const touch1 = (e as TouchEvent).touches[1];\n const cur = this.scaleTouchStore;\n this.scaleTouchStore = Math.abs(\n (touch1.clientX - touch0.clientX) * (touch1.clientY - touch0.clientY)\n );\n this.setScale(this.scaleTouchStore > cur, true);\n } else {\n if (!this.isCtrlKey) {\n this.update();\n }\n }\n }\n\n private handleMouseUp(e: MouseEvent | TouchEvent) {\n e.stopPropagation();\n if (this.lock) return;\n // 鼠标抬起则卸载放大器\n this.destroyMagnifier();\n if (this.isMobile) {\n if ((e as TouchEvent).touches?.length === 0) {\n this.isTouch2 = false;\n }\n if (Date.now() - this.dblTouchStore < this.dblTouch) {\n this.handleDblclick(e);\n return;\n }\n this.dblTouchStore = Date.now();\n }\n this.remmber = [];\n if (this.activeShape.type !== Shape.None && !this.isCtrlKey) {\n this.activeShape.dragging = false;\n if (this.activeShape.creating) {\n if ([Shape.Rect, Shape.Grid].includes(this.activeShape.type)) {\n const [[x0, y0], [x1, y1]] = this.activeShape.coor;\n if (\n Math.abs(x0 - x1) < this.MIN_WIDTH ||\n Math.abs(y0 - y1) < this.MIN_HEIGHT\n ) {\n this.dataset.pop();\n this.emit(\n \"warn\",\n `Width cannot be less than ${this.MIN_WIDTH},Height cannot be less than ${this.MIN_HEIGHT}`\n );\n } else {\n this.activeShape.coor = [\n [Math.min(x0, x1), Math.min(y0, y1)],\n [Math.max(x0, x1), Math.max(y0, y1)],\n ];\n this.activeShape.creating = false;\n this.emit(\"add\", this.activeShape);\n }\n } else if (this.activeShape.type === Shape.Circle) {\n if (this.activeShape.radius < this.MIN_RADIUS) {\n this.dataset.pop();\n this.emit(\"warn\", `Radius cannot be less than ${this.MIN_WIDTH}`);\n } else {\n this.activeShape.creating = false;\n this.emit(\"add\", this.activeShape);\n }\n } else if (\n [Shape.Brush, Shape.Eraser].includes(this.activeShape.type)\n ) {\n this.activeShape.creating = false;\n this.emit(\"add\", this.activeShape);\n }\n this.update();\n }\n }\n }\n\n private handleDblclick(e: MouseEvent | TouchEvent) {\n e.stopPropagation();\n if (this.lock) return;\n if ([Shape.Polygon, Shape.Line].includes(this.activeShape.type)) {\n const canPolygon =\n this.activeShape.type === Shape.Polygon &&\n this.activeShape.coor.length > 2;\n const canLine =\n this.activeShape.type === Shape.Line &&\n this.activeShape.coor.length > 1;\n // 对于多边形,如果达到最大点数也允许完成\n const canPolygonByMaxPoints =\n this.activeShape.type === Shape.Polygon &&\n this.activeShape.coor.length >= this.MAX_POLYGON_POINTS;\n // 对于折线,如果达到2个点也允许完成\n const canLineByTwoPoints =\n this.activeShape.type === Shape.Line &&\n this.activeShape.coor.length >= 2;\n if (\n canPolygon ||\n canLine ||\n canPolygonByMaxPoints ||\n canLineByTwoPoints\n ) {\n this.emit(\"add\", this.activeShape);\n this.activeShape.creating = false;\n this.update();\n }\n } else if ([Shape.Grid].includes(this.activeShape.type)) {\n // 双击切换网格分区选中状态\n if (this.activeShape.active) {\n this.activeShape.gridRects.forEach(\n (rect: { coor: Point[]; index: number }) => {\n if (this.isPointInRect(this.mouse, rect.coor)) {\n const thisIndex = this.activeShape.selected.findIndex(\n (x: number) => rect.index === x\n );\n if (thisIndex > -1) {\n this.activeShape.selected.splice(thisIndex, 1);\n } else {\n this.activeShape.selected.push(rect.index);\n }\n }\n }\n );\n this.update();\n }\n }\n }\n private handleKeydown(e: KeyboardEvent) {\n if (e.code === this.ctrlCode) {\n this.isCtrlKey = true;\n }\n }\n\n private handleKeyup(e: KeyboardEvent) {\n if (e.code === this.ctrlCode) {\n this.isCtrlKey = false;\n }\n if (this.lock || document.activeElement !== document.body || this.readonly)\n return;\n if (this.activeShape.type) {\n if (\n [Shape.Polygon, Shape.Line].includes(this.activeShape.type) &&\n e.key === \"Escape\"\n ) {\n // 对于多边形,如果已经达到最大点数,不应该再删除点\n const isPolygonAtMaxPoints =\n this.activeShape.type === Shape.Polygon &&\n this.activeShape.coor.length >= this.MAX_POLYGON_POINTS;\n // 对于折线,如果已经达到2个点,不应该再删除点\n const isLineAtTwoPoints =\n this.activeShape.type === Shape.Line &&\n this.activeShape.coor.length >= 2;\n\n if (\n this.activeShape.coor.length > 1 &&\n this.activeShape.creating &&\n !isPolygonAtMaxPoints &&\n !isLineAtTwoPoints\n ) {\n this.activeShape.coor.pop();\n } else {\n this.deleteByIndex(this.activeShape.index);\n }\n this.update();\n } else if (e.key === \"Backspace\") {\n this.deleteByIndex(this.activeShape.index);\n }\n }\n }\n\n /** 初始化配置 */\n initSetting() {\n if (!this.canvas || !this.offScreen) return;\n const dpr = window.devicePixelRatio || 1;\n // 处理图片跨域问题\n this.image.crossOrigin = \"anonymous\";\n this.canvas.style.userSelect = \"none\";\n this.ctx = this.ctx || this.canvas.getContext(\"2d\", { alpha: this.alpha });\n this.WIDTH = this.canvas.clientWidth;\n this.HEIGHT = Math.round(this.canvas.clientHeight);\n this.canvas.width = this.WIDTH * dpr;\n this.canvas.height = this.HEIGHT * dpr;\n this.canvas.style.width = this.WIDTH + \"px\";\n this.canvas.style.height = this.HEIGHT + \"px\";\n this.offScreen.width = this.WIDTH;\n this.offScreen.height = this.HEIGHT;\n this.offScreenCtx =\n this.offScreenCtx ||\n this.offScreen.getContext(\"2d\", { willReadFrequently: true });\n this.ctx?.scale(dpr, dpr);\n }\n\n /** 初始化事件 */\n initEvents() {\n if (!this.canvas) return;\n this.image.addEventListener(\"load\", this.handleLoad);\n this.canvas.addEventListener(\"touchstart\", this.handleMouseDown);\n this.canvas.addEventListener(\"touchmove\", this.handleMouseMove);\n this.canvas.addEventListener(\"touchend\", this.handleMouseUp);\n this.canvas.addEventListener(\"contextmenu\", this.handleContextmenu);\n // @ts-ignore\n this.canvas.addEventListener(\"mousewheel\", this.handleMousewheel);\n this.canvas.addEventListener(\"wheel\", this.handleMousewheel);\n this.canvas.addEventListener(\"mousedown\", this.handleMouseDown);\n this.canvas.addEventListener(\"mousemove\", this.handleMouseMove);\n this.canvas.addEventListener(\"mouseup\", this.handleMouseUp);\n this.canvas.addEventListener(\"dblclick\", this.handleDblclick);\n document.body.addEventListener(\"keydown\", this.handleKeydown, true);\n document.body.addEventListener(\"keyup\", this.handleKeyup, true);\n }\n\n /**\n * 添加/切换图片\n * @param source 图片链接或图片对象\n */\n setImage(source: string | HTMLImageElement) {\n if (typeof source === \"string\") {\n this.image.src = source;\n } else {\n this.image = source;\n this.image.crossOrigin = \"anonymous\";\n if (this.image.complete) {\n this.handleLoad();\n } else {\n this.image.addEventListener(\"load\", this.handleLoad);\n }\n }\n }\n\n /**\n * 设置数据\n * @param data Array\n */\n setData(data: AllShape[]) {\n setTimeout(() => {\n const initdata: AllShape[] = [];\n data.forEach((item: any, index) => {\n if (Object.prototype.toString.call(item).includes(\"Object\")) {\n let shape: any;\n switch (item.type) {\n case Shape.Rect:\n shape = new Rect(item, index, this);\n break;\n case Shape.Polygon:\n shape = new Polygon(item, index, this);\n break;\n case Shape.Dot:\n shape = new Dot(item, index, this);\n break;\n case Shape.Line:\n shape = new Line(item, index, this);\n break;\n case Shape.Circle:\n shape = new Circle(item, index, this);\n break;\n case Shape.Grid:\n shape = new Grid(item, index, this);\n break;\n case Shape.Brush:\n shape = new Brush(item, index, this);\n break;\n case Shape.Eraser:\n shape = new Eraser(item, index, this);\n break;\n case Shape.Ellipse:\n shape = new Ellipse(item, index, this);\n break;\n default:\n console.warn(\"Invalid shape\", item);\n break;\n }\n [\n Shape.Rect,\n Shape.Polygon,\n Shape.Dot,\n Shape.Line,\n Shape.Circle,\n Shape.Grid,\n Shape.Brush,\n Shape.Eraser,\n Shape.Ellipse,\n ].includes(item.type) &&\n shape &&\n initdata.push(shape);\n } else {\n console.warn(\"Shape must be an enumerable Object.\", item);\n }\n });\n this.dataset = initdata;\n this.update();\n });\n }\n\n /**\n * 判断是否在标注实例上\n * @param mousePoint 点击位置\n * @returns\n */\n hitOnShape(mousePoint: Point): [number, AllShape] {\n let hitShapeIndex = -1;\n let hitShape: any;\n for (let i = this.dataset.length - 1; i > -1; i--) {\n const shape = this.dataset[i];\n if (shape.hide) continue;\n if (\n (shape.type === Shape.Dot &&\n this.isPointInCircle(\n mousePoint,\n shape.coor as Point,\n this.ctrlRadius\n )) ||\n (shape.type === Shape.Circle &&\n this.isPointInCircle(\n mousePoint,\n shape.coor as Point,\n (shape as Circle).radius * this.scale\n )) ||\n (shape.type === Shape.Rect &&\n this.isPointInRect(mousePoint, (shape as Rect).coor)) ||\n (shape.type === Shape.Polygon &&\n this.isPointInPolygon(mousePoint, (shape as Polygon).coor)) ||\n (shape.type === Shape.Line &&\n this.isPointInLine(mousePoint, (shape as Line).coor)) ||\n (shape.type === Shape.Grid &&\n this.isPointInRect(mousePoint, (shape as Grid).coor))\n ) {\n if (this.focusMode && !shape.active) continue;\n hitShapeIndex = i;\n hitShape = shape;\n break;\n }\n }\n return [hitShapeIndex, hitShape];\n }\n\n /**\n * 判断鼠标是否在背景图内部\n * @param e MouseEvent\n * @returns 布尔值\n */\n isInBackground(e: MouseEvent | TouchEvent): boolean {\n const { mouseX, mouseY } = this.mergeEvent(e);\n return (\n mouseX >= this.originX &&\n mouseY >= this.originY &&\n mouseX <= this.originX + this.IMAGE_ORIGIN_WIDTH * this.scale &&\n mouseY <= this.originY + this.IMAGE_ORIGIN_HEIGHT * this.scale\n );\n }\n\n /**\n * 判断是否在矩形内\n * @param point 坐标\n * @param coor 区域坐标\n * @returns 布尔值\n */\n isPointInRect(point: Point, coor: Point[]): boolean {\n const [x, y] = point;\n const [[x0, y0], [x1, y1]] = coor.map((a) => a.map((b) => b * this.scale));\n return (\n x0 + this.originX <= x &&\n x <= x1 + this.originX &&\n y0 + this.originY <= y &&\n y <= y1 + this.originY\n );\n }\n\n /**\n * 判断是否在多边形内\n * @param point 坐标\n * @param coor 区域坐标\n * @returns 布尔值\n */\n isPointInPolygon(point: Point, coor: Point[]): boolean {\n if (!this.offScreenCtx) return false;\n this.offScreenCtx.save();\n this.offScreenCtx.clearRect(0, 0, this.WIDTH, this.HEIGHT);\n this.offScreenCtx.translate(this.originX, this.originY);\n this.offScreenCtx.beginPath();\n coor.forEach((pt, i) => {\n const [x, y] = pt.map((a) => Math.round(a * this.scale));\n if (i === 0) {\n this.offScreenCtx?.moveTo(x, y);\n } else {\n this.offScreenCtx?.lineTo(x, y);\n }\n });\n this.offScreenCtx.closePath();\n this.offScreenCtx.fill();\n const areaData = this.offScreenCtx.getImageData(\n 0,\n 0,\n this.WIDTH,\n this.HEIGHT\n );\n const index = (point[1] - 1) * this.WIDTH * 4 + point[0] * 4;\n this.offScreenCtx.restore();\n return areaData.data[index + 3] !== 0;\n }\n\n /**\n * 判断是否在圆内\n * @param point 坐标\n * @param center 圆心\n * @param r 半径\n * @param needScale 是否为圆形点击检测\n * @returns 布尔值\n */\n isPointInCircle(point: Point, center: Point, r: number): boolean {\n const [x, y] = point;\n const [x0, y0] = center.map((a) => a * this.scale);\n const distance = Math.sqrt(\n (x0 + this.originX - x) ** 2 + (y0 + this.originY - y) ** 2\n );\n return distance <= r;\n }\n\n /**\n * 判断是否在折线内\n * @param point 坐标\n * @param coor 区域坐标\n * @returns 布尔值\n */\n isPointInLine(point: Point, coor: Point[]): boolean {\n if (!this.offScreenCtx) return false;\n this.offScreenCtx.save();\n this.offScreenCtx.clearRect(0, 0, this.WIDTH, this.HEIGHT);\n this.offScreenCtx.translate(this.originX, this.originY);\n this.offScreenCtx.lineWidth = this.lineWidth > 5 ? this.lineWidth : 5;\n this.offScreenCtx.beginPath();\n coor.forEach((pt, i) => {\n const [x, y] = pt.map((a) => Math.round(a * this.scale));\n if (i === 0) {\n this.offScreenCtx?.moveTo(x, y);\n } else {\n this.offScreenCtx?.lineTo(x, y);\n }\n });\n this.offScreenCtx.stroke();\n const areaData = this.offScreenCtx.getImageData(\n 0,\n 0,\n this.WIDTH,\n this.HEIGHT\n );\n const index = (point[1] - 1) * this.WIDTH * 4 + point[0] * 4;\n this.offScreenCtx.restore();\n return areaData.data[index + 3] !== 0;\n }\n\n /**\n * 绘制矩形\n * @param shape 标注实例\n * @returns\n */\n drawRect(shape: Rect, sub?: Record<string, any>) {\n if (!this.ctx || shape.coor.length !== 2) return;\n const {\n strokeStyle = \"\",\n fillStyle = \"\",\n active,\n creating,\n coor,\n lineWidth,\n rotation,\n } = shape;\n const [[x0, y0], [x1, y1]] = coor.map((a: Point) =>\n a.map((b) => Math.round(b * this.scale))\n );\n const centerX = (x0 + x1) / 2;\n const centerY = (y0 + y1) / 2;\n const w = x1 - x0;\n const h = y1 - y0;\n\n this.ctx.save();\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n if (sub?.isSelected) {\n this.ctx.fillStyle = sub?.selectedFillStyle || fillStyle;\n } else {\n this.ctx.fillStyle =\n active || creating ? this.activeFillStyle : fillStyle;\n }\n this.ctx.strokeStyle =\n active || creating ? this.activeStrokeStyle : strokeStyle;\n\n // 应用旋转\n this.ctx.translate(centerX, centerY);\n this.ctx.rotate(rotation);\n this.ctx.translate(-centerX, -centerY);\n\n if (!creating) this.ctx.fillRect(x0, y0, w, h);\n this.ctx.strokeRect(x0, y0, w, h);\n this.ctx.restore();\n this.drawLabel(coor[0], shape);\n }\n\n /**\n * 绘制多边形\n * @param shape 标注实例\n */\n drawPolygon(shape: Polygon) {\n if (!this.ctx) return;\n const {\n strokeStyle = \"\",\n fillStyle = \"\",\n active,\n creating,\n coor,\n lineWidth,\n } = shape;\n this.ctx.save();\n this.ctx.lineJoin = \"round\";\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n this.ctx.fillStyle = active || creating ? this.activeFillStyle : fillStyle;\n this.ctx.strokeStyle =\n active || creating ? this.activeStrokeStyle : strokeStyle;\n this.ctx.beginPath();\n coor.forEach((el: Point, i) => {\n const [x, y] = el.map((a) => Math.round(a * this.scale));\n if (i === 0) {\n this.ctx?.moveTo(x, y);\n } else {\n this.ctx?.lineTo(x, y);\n }\n });\n\n // 如果正在创建且达到了最大点数,则自动闭合\n const shouldClose = creating && coor.length >= this.MAX_POLYGON_POINTS;\n\n if (creating && !shouldClose) {\n const [x, y] = this.mouse || [];\n this.ctx.lineTo(x - this.originX, y - this.originY);\n } else if (coor.length > 2 || shouldClose) {\n this.ctx.closePath();\n }\n this.ctx.fill();\n this.ctx.stroke();\n this.ctx.restore();\n this.drawLabel(coor[0], shape);\n }\n\n /**\n * 绘制点\n * @param shape 标注实例\n */\n drawDot(shape: Dot) {\n if (!this.ctx) return;\n const {\n strokeStyle = \"\",\n creating,\n fillStyle = \"\",\n active,\n coor,\n lineWidth,\n } = shape;\n const [x, y] = coor.map((a) => a * this.scale);\n this.ctx.save();\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n this.ctx.fillStyle = active || creating ? this.activeFillStyle : fillStyle;\n this.ctx.strokeStyle = active ? this.activeStrokeStyle : strokeStyle;\n this.ctx.beginPath();\n this.ctx.arc(x, y, this.ctrlRadius, 0, 2 * Math.PI, true);\n this.ctx.fill();\n this.ctx.arc(x, y, this.ctrlRadius, 0, 2 * Math.PI, true);\n this.ctx.stroke();\n this.ctx.restore();\n this.drawLabel(coor as Point, shape);\n }\n\n /**\n * 绘制圆\n * @param shape 标注实例\n */\n drawCirle(shape: Circle) {\n if (!this.ctx) return;\n const {\n strokeStyle = \"\",\n fillStyle = \"\",\n active,\n coor,\n creating,\n radius,\n ctrlsData,\n lineWidth,\n } = shape;\n const [x, y] = coor.map((a) => a * this.scale);\n this.ctx.save();\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n this.ctx.fillStyle = active || creating ? this.activeFillStyle : fillStyle;\n this.ctx.strokeStyle =\n active || creating ? this.activeStrokeStyle : strokeStyle;\n this.ctx.beginPath();\n this.ctx.arc(x, y, radius * this.scale, 0, 2 * Math.PI, true);\n this.ctx.fill();\n this.ctx.arc(x, y, radius * this.scale, 0, 2 * Math.PI, true);\n this.ctx.stroke();\n this.ctx.restore();\n this.drawLabel(ctrlsData[0] as Point, shape);\n }\n\n /**\n * 绘制椭圆\n * @param shape 标注实例\n */\n drawEllipse(shape: Ellipse) {\n if (!this.ctx) return;\n const {\n strokeStyle = \"\",\n fillStyle = \"\",\n active,\n coor,\n creating,\n radiusX,\n radiusY,\n rotation,\n lineWidth,\n } = shape;\n const [x, y] = coor.map((a) => a * this.scale);\n const scaledRadiusX = radiusX * this.scale;\n const scaledRadiusY = radiusY * this.scale;\n\n this.ctx.save();\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n this.ctx.fillStyle = active || creating ? this.activeFillStyle : fillStyle;\n this.ctx.strokeStyle =\n active || creating ? this.activeStrokeStyle : strokeStyle;\n\n this.ctx.beginPath();\n // 使用 ellipse 方法绘制椭圆\n this.ctx.ellipse(\n x,\n y,\n scaledRadiusX,\n scaledRadiusY,\n rotation,\n 0,\n 2 * Math.PI,\n true\n );\n this.ctx.fill();\n this.ctx.ellipse(\n x,\n y,\n scaledRadiusX,\n scaledRadiusY,\n rotation,\n 0,\n 2 * Math.PI,\n true\n );\n this.ctx.stroke();\n\n this.ctx.restore();\n this.drawLabel(shape.ctrlsData[0] as Point, shape);\n }\n\n /**\n * 绘制折线\n * @param shape 标注实例\n */\n drawLine(shape: Line) {\n if (!this.ctx) return;\n const { strokeStyle = \"\", active, creating, coor, lineWidth } = shape;\n this.ctx.save();\n this.ctx.lineJoin = \"round\";\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n this.ctx.strokeStyle =\n active || creating ? this.activeStrokeStyle : strokeStyle;\n this.ctx.beginPath();\n coor.forEach((el: Point, i) => {\n const [x, y] = el.map((a) => Math.round(a * this.scale));\n if (i === 0) {\n this.ctx?.moveTo(x, y);\n } else {\n this.ctx?.lineTo(x, y);\n }\n });\n\n // 如果正在创建且达到了2个点,则自动结束\n const shouldEnd = creating && coor.length >= 2;\n\n if (creating && !shouldEnd) {\n const [x, y] = this.mouse || [];\n this.ctx.lineTo(x - this.originX, y - this.originY);\n } else if (coor.length > 1) {\n // 折线达到2个点后自动结束绘制\n }\n this.ctx.stroke();\n this.ctx.restore();\n this.drawLabel(coor[0], shape);\n }\n\n /**\n * 绘制网格\n * @param shape 标注实例\n * @returns\n */\n drawGrid(shape: Grid) {\n if (!this.ctx) return;\n if (shape.coor.length !== 2) return;\n const {\n strokeStyle = \"\",\n fillStyle = \"\",\n active,\n creating,\n coor,\n lineWidth,\n } = shape;\n const [[x0, y0], [x1, y1]] = coor.map((a: Point) =>\n a.map((b) => Math.round(b * this.scale))\n );\n this.ctx.save();\n this.ctx.lineWidth = lineWidth || this.lineWidth;\n this.ctx.fillStyle = active || creating ? this.activeFillStyle : fillStyle;\n this.ctx.strokeStyle =\n active || creating ? this.activeStrokeStyle : strokeStyle;\n shape.gridRects.forEach((rect: Rect, m) => {\n this.drawRect(rect, {\n selectedFillStyle:\n shape.selectedFillStyle || this.gridSelectedFillStyle,\n isSelected: shape.selected?.includes(m),\n });\n });\n const w = x1 - x0;\n const h = y1 - y0;\n if (!creating) this.ctx.fillRect(x0, y0, w, h);\n this.ctx.strokeRect(x0, y0, w, h);\n this.ctx.restore();\n this.drawLabel(coor[0], shape);\n }\n /**\n * 绘制画笔路径\n * @param shape 形状\n */\n drawBrushPath(shape: Brush) {\n if (!this.ctx) return;\n const { coor, brushSize = 1, brushStokeStyle = \"\" } = shape;\n this.ctx.save();\n this.ctx.globalCompositeOperation = \"source-over\"; // 正常绘制模式\n this.ctx.lineCap = \"round\";\n this.ctx.lineJoin = \"round\";\n this.ctx.lineWidth = Math.round(brushSize * this.scale);\n this.ctx.strokeStyle = brushStokeStyle;\n this.ctx.beginPath();\n coor.forEach((el: Point, i) => {\n const [x, y] = el.map((a) => Math.round(a * this.scale));\n if (i === 0) {\n this.ctx?.moveTo(x, y);\n } else {\n this.ctx?.lineTo(x, y);\n }\n });\n this.ctx.stroke();\n this.ctx.restore();\n }\n /**\n * 绘制橡皮擦路径\n * @param coor 折线坐标\n * @param shape 形状\n */\n drawEraserPath(shape: Eraser) {\n if (!this.ctx) return;\n const { coor, eraserSize = 1 } = shape;\n this.ctx.save();\n this.ctx.globalCompositeOperation = \"destination-out\";\n this.ctx.lineCap = \"round\";\n this.ctx.lineJoin = \"round\";\n this.ctx.lineWidth = Math.round(eraserSize * this.scale);\n this.ctx.beginPath();\n coor.forEach((el: Point, i) => {\n const [x, y] = el.map((a) => Math.round(a * this.scale));\n if (i === 0) {\n this.ctx?.moveTo(x, y);\n } else {\n this.ctx?.lineTo(x, y);\n }\n });\n this.ctx.stroke();\n this.ctx.restore();\n }\n /** 清除画布 */\n clearBrush() {\n const newDateset = this.dataset.filter(\n (el) => ![Shape.Brush, Shape.Eraser].includes(el.type)\n );\n this.setData(newDateset);\n }\n\n /**\n * 绘制控制点\n * @param point 坐标\n */\n drawCtrl(point: Point, color?: string) {\n if (!this.ctx) return;\n const [x, y] = point.map((a) => a * this.scale);\n this.ctx.save();\n this.ctx.beginPath();\n this.ctx.fillStyle = color || this.ctrlFillStyle;\n this.ctx.strokeStyle = this.ctrlStrokeStyle;\n this.ctx.arc(x, y, this.ctrlRadius, 0, 2 * Math.PI, true);\n this.ctx.fill();\n this.ctx.arc(x, y, this.ctrlRadius, 0, 2 * Math.PI, true);\n this.ctx.stroke();\n this.ctx.restore();\n }\n\n /**\n * 绘制控制点列表\n * @param shape 标注实例\n */\n drawCtrlList(shape: Rect | Polygon | Line | Circle | Ellipse) {\n shape.ctrlsData.forEach((point, i) => {\n if (shape.type === Shape.Circle) {\n if (i === 1) this.drawCtrl(point);\n } else if (shape.type === Shape.Ellipse) {\n // 对于椭圆,绘制所有控制点\n this.drawCtrl(point);\n } else {\n this.drawCtrl(\n point,\n shape.type === Shape.Rect && i === 8 ? \"yellow\" : undefined\n );\n }\n });\n }\n\n /**\n * 绘制label\n * @param point 位置\n * @param label 文本\n */\n drawLabel(point: Point, shape: AllShape) {\n const {\n label = \"\",\n labelFillStyle = \"\",\n labelFont = \"\",\n textFillStyle = \"\",\n hideLabel,\n labelUp,\n lineWidth,\n } = shape;\n const isHideLabel =\n typeof hideLabel === \"boolean\" ? hideLabel : this.hideLabel;\n const isLabelUp = typeof labelUp === \"boolean\" ? labelUp : this.labelUp;\n const currLineWidth = lineWidth || this.lineWidth;\n\n if (this.ctx && label.length && !isHideLabel) {\n this.ctx.font = labelFont || this.labelFont;\n const textPaddingLeft = 4;\n const textPaddingTop = 4;\n const newText =\n label.length < this.labelMaxLen + 1\n ? label\n : `${label.slice(0, this.labelMaxLen)}...`;\n const text = this.ctx.measureText(newText);\n const font = parseInt(this.ctx.font) - 4;\n const labelWidth = text.width + textPaddingLeft * 2;\n const labelHeight = font + textPaddingTop * 2;\n\n let [x, y] = point.map((a) => a * this.scale);\n\n // 对于矩形,如果存在旋转角度,需要调整label位置\n if (shape.type === Shape.Rect && (shape as Rect).rotation !== 0) {\n const rect = shape as Rect;\n const [[x0, y0], [x1, y1]] = rect.coor;\n const centerX = ((x0 + x1) / 2) * this.scale;\n const centerY = ((y0 + y1) / 2) * this.scale;\n\n // 将左上角点转换为相对于中心点的坐标\n const dx = x - centerX;\n const dy = y - centerY;\n\n // 应用旋转\n const rotatedX =\n dx * Math.cos(rect.rotation) - dy * Math.sin(rect.rotation);\n const rotatedY =\n dx * Math.sin(rect.rotation) + dy * Math.cos(rect.rotation);\n\n // 转换回绝对坐标\n x = rotatedX + centerX;\n y = rotatedY + centerY;\n }\n\n const toleft =\n this.IMAGE_ORIGIN_WIDTH - point[0] < labelWidth / this.scale;\n const toTop =\n this.IMAGE_ORIGIN_HEIGHT - point[1] < labelHeight / this.scale;\n const toTop2 = point[1] > labelHeight / this.scale;\n const isup = isLabelUp ? toTop2 : toTop;\n this.ctx.save();\n this.ctx.fillStyle = labelFillStyle || this.labelFillStyle;\n this.ctx.fillRect(\n toleft\n ? x - text.width - textPaddingLeft - currLineWidth / 2\n : x + currLineWidth / 2,\n isup ? y - labelHeight - currLineWidth / 2 : y + currLineWidth / 2,\n labelWidth,\n labelHeight\n );\n this.ctx.fillStyle = textFillStyle || this.textFillStyle;\n this.ctx.fillText(\n newText,\n toleft ? x - text.width : x + textPaddingLeft + currLineWidth / 2,\n isup\n ? y - labelHeight + font + textPaddingTop\n : y + font + textPaddingTop + currLineWidth / 2,\n 180\n );\n this.ctx.restore();\n }\n }\n\n /**\n * 更新画布\n */\n update() {\n window.cancelAnimationFrame(this.timer);\n this.timer = window.requestAnimationFrame(() => {\n if (!this.ctx) return;\n this.ctx.save();\n this.ctx.clearRect(0, 0, this.WIDTH, this.HEIGHT);\n this.ctx.translate(this.originX, this.originY);\n\n const renderList = this.focusMode\n ? this.activeShape.type\n ? [this.activeShape]\n : []\n : this.dataset;\n const BrushAndErasers = renderList.filter(\n (item) => item.type === Shape.Brush || item.type === Shape.Eraser\n );\n for (let i = 0; i < BrushAndErasers.length; i++) {\n const shape = BrushAndErasers[i];\n if (shape.hide) continue;\n switch (shape.type) {\n case Shape.Brush:\n shape.brushSize = shape.brushSize ?? this.brushSize;\n shape.brushStokeStyle =\n shape.brushStokeStyle ?? this.brushStokeStyle;\n this.drawBrushPath(shape as Brush);\n break;\n case Shape.Eraser:\n shape.eraserSize = shape.eraserSize ?? this.eraserSize;\n this.drawEraserPath(shape as Eraser);\n break;\n default:\n break;\n }\n }\n const NormalShapes = renderList.filter(\n (item) => item.type !== Shape.Brush && item.type !== Shape.Eraser\n );\n for (let i = 0; i < NormalShapes.length; i++) {\n const shape = NormalShapes[i];\n if (shape.hide) continue;\n switch (shape.type) {\n case Shape.Rect:\n this.drawRect(shape as Rect);\n break;\n case Shape.Polygon:\n this.drawPolygon(shape as Polygon);\n break;\n case Shape.Dot:\n this.drawDot(shape as Dot);\n break;\n case Shape.Line:\n this.drawLine(shape as Line);\n break;\n case Shape.Circle:\n this.drawCirle(shape as Circle);\n break;\n case Shape.Ellipse:\n this.drawEllipse(shape as Ellipse);\n break;\n case Shape.Grid:\n this.drawGrid(shape as Grid);\n break;\n default:\n break;\n }\n }\n if (!this.isCtrlKey && this.showCross) {\n this.drawLine(this.crossX);\n this.drawLine(this.crossY);\n }\n if (\n [\n Shape.Rect,\n Shape.Polygon,\n Shape.Line,\n Shape.Circle,\n Shape.Grid,\n Shape.Ellipse,\n ].includes(this.activeShape.type) &&\n !this.activeShape.hide\n ) {\n this.drawCtrlList(this.activeShape);\n }\n this.ctx.globalCompositeOperation = \"destination-over\";\n if (this.IMAGE_WIDTH && this.IMAGE_HEIGHT) {\n this.ctx.drawImage(\n this.image,\n 0,\n 0,\n this.IMAGE_WIDTH,\n this.IMAGE_HEIGHT\n );\n }\n this.ctx.globalCompositeOperation = \"source-over\";\n this.ctx.restore();\n this.emit(\"updated\", this.dataset);\n });\n }\n\n /**\n * 通过索引删除指定形状\n * @param index number\n */\n deleteByIndex(index: number) {\n const num = this.dataset.findIndex((x) => x.index === index);\n if (num > -1) {\n this.emit(\"delete\", this.dataset[num]);\n this.dataset.splice(num, 1);\n this.dataset.forEach((item, i) => {\n item.index = i;\n });\n this.update();\n }\n }\n\n /**\n * 通过uuid删除指定形状\n * @param index string\n */\n deleteByUuid(uuid: string) {\n const target = this.dataset.find((x) => x.uuid === uuid);\n if (target) {\n this.emit(\"delete\", target);\n this.dataset = this.dataset.filter((x) => x.uuid !== uuid);\n this.update();\n }\n }\n\n /**\n * 计算缩放步长\n */\n calcStep(flag = \"\") {\n if (this.IMAGE_WIDTH < this.WIDTH && this.IMAGE_HEIGHT < this.HEIGHT) {\n if (flag === \"\" || flag === \"b\") {\n this.setScale(true, false, true);\n this.calcStep(\"b\");\n }\n }\n if (this.IMAGE_WIDTH > this.WIDTH || this.IMAGE_HEIGHT > this.HEIGHT) {\n if (flag === \"\" || flag === \"s\") {\n this.setScale(false, false, true);\n this.calcStep(\"s\");\n }\n }\n }\n\n /**\n * 缩放\n * @param type true放大5%,false缩小5%\n * @param center 缩放中心 center|mouse\n * @param pure 不绘制\n */\n setScale(type: boolean, byMouse = false, pure = false) {\n if (this.lock) return;\n if (\n (!type && this.imageMin < 20) ||\n (type && this.IMAGE_WIDTH > this.imageOriginMax * 100)\n )\n return;\n if (type) {\n this.scaleStep++;\n } else {\n this.scaleStep--;\n }\n let realToLeft = 0;\n let realToRight = 0;\n const [x, y] = this.mouse || [];\n if (byMouse) {\n realToLeft = (x - this.originX) / this.scale;\n realToRight = (y - this.originY) / this.scale;\n }\n const abs = Math.abs(this.scaleStep);\n const width = this.IMAGE_WIDTH;\n\n this.IMAGE_WIDTH = Math.round(\n this.IMAGE_ORIGIN_WIDTH * (this.scaleStep >= 0 ? 1.05 : 0.95) ** abs\n );\n this.IMAGE_HEIGHT = Math.round(\n this.IMAGE_ORIGIN_HEIGHT * (this.scaleStep >= 0 ? 1.05 : 0.95) ** abs\n );\n if (byMouse) {\n this.originX = x - realToLeft * this.scale;\n this.originY = y - realToRight * this.scale;\n } else {\n const scale = this.IMAGE_WIDTH / width;\n this.originX = this.WIDTH / 2 - (this.WIDTH / 2 - this.originX) * scale;\n this.originY = this.HEIGHT / 2 - (this.HEIGHT / 2 - this.originY) * scale;\n }\n if (!pure) {\n this.update();\n }\n }\n\n /**\n * 适配背景图\n */\n fitZoom() {\n this.calcStep();\n if (this.IMAGE_HEIGHT / this.IMAGE_WIDTH >= this.HEIGHT / this.WIDTH) {\n this.IMAGE_WIDTH =\n this.IMAGE_ORIGIN_WIDTH / (this.IMAGE_ORIGIN_HEIGHT / this.HEIGHT);\n this.IMAGE_HEIGHT = this.HEIGHT;\n } else {\n this.IMAGE_WIDTH = this.WIDTH;\n this.IMAGE_HEIGHT =\n this.IMAGE_ORIGIN_HEIGHT / (this.IMAGE_ORIGIN_WIDTH / this.WIDTH);\n }\n this.originX = (this.WIDTH - this.IMAGE_WIDTH) / 2;\n this.originY = (this.HEIGHT - this.IMAGE_HEIGHT) / 2;\n this.update();\n }\n\n /**\n * 设置专注模式\n * @param type {boolean}\n */\n setFocusMode(type: boolean) {\n this.focusMode = type;\n this.update();\n }\n\n /**\n * 销毁\n */\n destroy() {\n if (!this.canvas) return;\n this.image.removeEventListener(\"load\", this.handleLoad);\n this.canvas.removeEventListener(\"contextmenu\", this.handleContextmenu);\n // @ts-ignore\n this.canvas.removeEventListener(\"mousewheel\", this.handleMousewheel);\n this.canvas.removeEventListener(\"wheel\", this.handleMousewheel);\n this.canvas.removeEventListener(\"mousedown\", this.handleMouseDown);\n this.canvas.removeEventListener(\"touchend\", this.handleMouseDown);\n this.canvas.removeEventListener(\"mousemove\", this.handleMouseMove);\n this.canvas.removeEventListener(\"touchmove\", this.handleMouseMove);\n this.canvas.removeEventListener(\"mouseup\", this.handleMouseUp);\n this.canvas.removeEventListener(\"touchend\", this.handleMouseUp);\n this.canvas.removeEventListener(\"dblclick\", this.handleDblclick);\n document.body.removeEventListener(\"keydown\", this.handleKeydown, true);\n document.body.removeEventListener(\"keyup\", this.handleKeyup, true);\n this.canvas.width = this.WIDTH;\n this.canvas.height = this.HEIGHT;\n this.canvas.style.width = \"\";\n this.canvas.style.height = \"\";\n this.canvas.style.userSelect = \"\";\n }\n\n /**\n * 重新设置画布大小\n */\n resize() {\n if (!this.canvas) return;\n this.canvas.removeAttribute(\"width\");\n this.canvas.removeAttribute(\"height\");\n this.canvas.style.width = \"\";\n this.canvas.style.height = \"\";\n this.initSetting();\n this.update();\n }\n}\n","export function createUuid(): string {\n const s: any[] = [];\n const hexDigits = \"0123456789abcdef\";\n for (let i = 0; i < 36; i++) {\n const m = Math.floor(Math.random() * 0x10);\n s[i] = hexDigits.slice(m, m + 1);\n }\n s[14] = \"4\";\n const n = (s[19] & 0x3) | 0x8;\n s[19] = hexDigits.slice(n, n + 1);\n s[8] = s[13] = s[18] = s[23] = \"-\";\n const uuid = s.join(\"\");\n return uuid;\n}\n","import Shape from './Shape';\n\nexport default class Rect extends Shape {\n public type = 1\n /** 旋转角度(弧度) */\n public rotation: number = 0\n /** 是否显示旋转控制点 */\n public showRotation: boolean | undefined\n constructor(item: any, index: number, base: any) {\n super(item, index)\n this.lineWidth = item.lineWidth ?? base.lineWidth\n this.fillStyle = item.fillStyle ?? base.fillStyle\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle\n this.showRotation = item.showRotation ?? base.showRotation\n }\n get ctrlsData() {\n const [[x0, y0], [x1, y1]] = this.coor;\n const centerX = (x0 + x1) / 2;\n const centerY = (y0 + y1) / 2;\n const width = x1 - x0;\n const height = y1 - y0;\n\n // 基础控制点(8个边角和中点控制点)\n const baseCtrls = [\n [x0, y0],\n [x0 + width / 2, y0],\n [x1, y0],\n [x1, y0 + height / 2],\n [x1, y1],\n [x0 + width / 2, y1],\n [x0, y1],\n [x0, y0 + height / 2]\n ];\n\n // 如果需要显示旋转控制点,则添加到控制点数组中\n if (this.showRotation) {\n baseCtrls.push([centerX, y0 - 20, 'green']);\n }\n\n // 如果矩形没有旋转,直接返回控制点\n if (this.rotation === 0) {\n return baseCtrls;\n }\n\n // 应用旋转变换到所有控制点\n return baseCtrls.map(([x, y]) => {\n // 将点转换为相对于中心点的坐标\n const dx = x - centerX;\n const dy = y - centerY;\n\n // 应用旋转\n const rotatedX = dx * Math.cos(this.rotation) - dy * Math.sin(this.rotation);\n const rotatedY = dx * Math.sin(this.rotation) + dy * Math.cos(this.rotation);\n\n // 转换回绝对坐标\n return [rotatedX + centerX, rotatedY + centerY];\n });\n }\n\n /** 获取矩形的中心点 */\n get center(): [number, number] {\n const [[x0, y0], [x1, y1]] = this.coor;\n return [(x0 + x1) / 2, (y0 + y1) / 2];\n }\n}\n","import Shape from './Shape';\n\nexport default class Polygon extends Shape {\n public type = 2\n constructor(item: any, index: number, base: any) {\n super(item, index)\n this.fillStyle = item.fillStyle ?? base.fillStyle\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle\n }\n get ctrlsData() {\n return this.coor.length > 2 ? this.coor : [];\n }\n}\n","import Shape from './Shape';\n\nexport default class Dot extends Shape {\n public type = 3\n constructor(item: any, index: number, base: any) {\n super(item, index)\n this.fillStyle = item.fillStyle ?? base.fillStyle\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle\n }\n}\n","export default class EventBus {\n private _eventTree: Record<string, any> = {}\n /**\n * 注册事件\n * @param eventName 事件名称\n * @param cb 回调方法\n */\n on(eventName: string, cb: Function) {\n const fns = this._eventTree[eventName];\n if (Array.isArray(fns)) {\n fns.push(cb);\n } else {\n this._eventTree[eventName] = [cb];\n }\n }\n\n /**\n * 触发事件\n * @param eventName 事件名称\n * @param payload 传递参数\n */\n emit(eventName: string, ...payload: any) {\n const fns = this._eventTree[eventName];\n if (Array.isArray(fns)) {\n fns.forEach((fn) => fn(...payload));\n }\n }\n\n /**\n * 注销事件\n * @param eventName 事件名称\n * @param cb 传递参数\n */\n off(eventName: string, cb: Function) {\n const fns = this._eventTree[eventName];\n const index = fns.find((fn: Function) => fn === cb);\n if (Array.isArray(fns) && index) {\n fns.splice(index, 1);\n }\n }\n}\n","import Shape from './Shape';\n\nexport default class Line extends Shape {\n public type = 4\n constructor(item: any, index: number, base: any) {\n super(item, index)\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle\n }\n get ctrlsData() {\n return this.coor.length > 1 ? this.coor : [];\n }\n}\n","import Shape from './Shape';\n\nexport default class Circle extends Shape {\n public type = 5\n public radius = 0\n constructor(item: any, index: number, base: any) {\n super(item, index)\n this.radius = item.radius || this.radius\n this.fillStyle = item.fillStyle ?? base.fillStyle\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle\n }\n get ctrlsData() {\n const [x, y] = this.coor\n return [\n [x, y - this.radius],\n [x + this.radius, y],\n [x, y + this.radius],\n [x - this.radius, y]\n ]\n }\n}\n","import Shape from './Shape';\nimport Rect from './Rect'\n\nexport default class Grid extends Shape {\n public type = 6\n public row = 1\n public col = 1\n public selected: number[] = []\n public selectedFillStyle: string | undefined\n\n constructor(item: any, index: number, base: any) {\n super(item, index)\n this.row = item.row > 0 ? item.row : this.row\n this.col = item.col > 0 ? item.col : this.col\n this.selected = Array.isArray(item.selected) ? item.selected : []\n this.fillStyle = item.fillStyle ?? base.fillStyle\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle\n }\n\n get ctrlsData() {\n const [[x0, y0], [x1, y1]] = this.coor;\n return [\n [x0, y0],\n [x0 + (x1 - x0) / 2, y0],\n [x1, y0],\n [x1, y0 + (y1 - y0) / 2],\n [x1, y1],\n [x0 + (x1 - x0) / 2, y1],\n [x0, y1],\n [x0, y0 + (y1 - y0) / 2],\n ];\n }\n\n get gridRects() {\n const [[x0, y0], [x1, y1]] = this.coor;\n const { row, col, strokeStyle, fillStyle, active, creating, lineWidth } = this;\n const w = (x1 - x0) / this.col;\n const h = (y1 - y0) / this.row;\n const list: Rect[] = []\n for (let i = 0; i < row; i++) {\n for (let j = 0; j < col; j++) {\n const startPoint = [x0 + j * w, y0 + i * h];\n const index = i * col + j;\n const shape = new Rect({\n coor: [startPoint, [startPoint[0] + w, startPoint[1] + h]],\n strokeStyle, fillStyle, active, creating, lineWidth\n }, index, {});\n list.push(shape)\n }\n }\n return list;\n }\n}\n","import Shape from './Shape';\nimport { Point } from '../index';\n\nexport default class Brush extends Shape {\n public type = 7;\n public coor: Point[] = [];\n public brushSize: number | undefined;\n public brushStokeStyle: string | undefined;\n\n constructor(data: any, index: number, base: any) {\n super(data, index);\n this.brushSize = data.brushSize ?? base.brushSize\n this.brushStokeStyle = data.brushStokeStyle ?? base.brushStokeStyle\n this.coor = data.coor\n }\n}\n","import Shape from './Shape';\nimport { Point } from '../index';\n\nexport default class Eraser extends Shape {\n public type = 8;\n public coor: Point[] = [];\n public eraserSize: number | undefined;\n\n constructor(data: any, index: number, base: any) {\n super(data, index);\n this.eraserSize = data.eraserSize ?? base.eraserSize;\n this.coor = data.coor;\n }\n}\n","import Shape from \"./Shape\";\r\n\r\nexport default class Ellipse extends Shape {\r\n public type = 9; // 椭圆类型\r\n public radiusX = 0; // 水平半径\r\n public radiusY = 0; // 垂直半径\r\n public rotation = 0; // 旋转角度(弧度)\r\n\r\n constructor(item: any, index: number, base: any) {\r\n super(item, index);\r\n this.radiusX = item.radiusX || this.radiusX;\r\n this.radiusY = item.radiusY || this.radiusY;\r\n this.rotation = item.rotation || this.rotation;\r\n this.fillStyle = item.fillStyle ?? base.fillStyle;\r\n this.strokeStyle = item.strokeStyle ?? base.strokeStyle;\r\n this.lineWidth = item.lineWidth ?? base.lineWidth;\r\n }\r\n\r\n get ctrlsData() {\r\n const [x, y] = this.coor;\r\n // 返回椭圆的控制点:上、右、下、左四个点\r\n return [\r\n [x, y - this.radiusY], // 上方控制点\r\n [x + this.radiusX, y], // 右方控制点\r\n [x, y + this.radiusY], // 下方控制点\r\n [x - this.radiusX, y], // 左方控制点\r\n ];\r\n }\r\n\r\n // 获取椭圆的边界框\r\n get boundingBox() {\r\n const [x, y] = this.coor;\r\n return [\r\n [x - this.radiusX, y - this.radiusY], // 左上角\r\n [x + this.radiusX, y + this.radiusY], // 右下角\r\n ];\r\n }\r\n\r\n // 检查点是否在椭圆内\r\n isPointInEllipse(pointX: number, pointY: number) {\r\n const [cx, cy] = this.coor;\r\n // 考虑旋转的点是否在椭圆内的检测\r\n if (this.rotation !== 0) {\r\n // 将点绕椭圆中心反向旋转\r\n const cos = Math.cos(-this.rotation);\r\n const sin = Math.sin(-this.rotation);\r\n const dx = pointX - cx;\r\n const dy = pointY - cy;\r\n const rotatedX = dx * cos - dy * sin;\r\n const rotatedY = dx * sin + dy * cos;\r\n\r\n // 在未旋转的椭圆中检查点\r\n return (\r\n (rotatedX * rotatedX) / (this.radiusX * this.radiusX) +\r\n (rotatedY * rotatedY) / (this.radiusY * this.radiusY) <=\r\n 1\r\n );\r\n } else {\r\n // 无旋转情况下的简单检查\r\n const dx = (pointX - cx) / this.radiusX;\r\n const dy = (pointY - cy) / this.radiusY;\r\n return dx * dx + dy * dy <= 1;\r\n }\r\n }\r\n}\r\n"],"names":["Shape","item","index","this","label","coor","active","creating","dragging","uuid","s","hexDigits","i","m","Math","floor","random","slice","n","join","createUuid","Object","assign","Rect","_super","base","_this","call","type","rotation","lineWidth","_a","fillStyle","_b","strokeStyle","_c","showRotation","_d","__extends","defineProperty","prototype","get","__read","x0","y0","x1","y1","centerX","centerY","width","height","baseCtrls","push","map","x","y","dx","dy","rotatedX","cos","sin","rotatedY","Polygon","length","Dot","EventBus","_eventTree","on","eventName","cb","fns","Array","isArray","emit","payload","_i","arguments","forEach","fn","apply","__spreadArray","off","find","splice","Line","Circle","radius","Grid","row","col","selected","w","h","list","j","startPoint","shape","Brush","data","brushSize","brushStokeStyle","Eraser","eraserSize","Ellipse","radiusX","radiusY","isPointInEllipse","pointX","pointY","cx","cy","CanvasSelect","el","src","version","pkg","lock","readonly","MIN_WIDTH","MIN_HEIGHT","MIN_RADIUS","MAX_POLYGON_POINTS","activeStrokeStyle","activeFillStyle","ctrlStrokeStyle","ctrlFillStyle","ctrlRadius","hideLabel","labelFillStyle","labelFont","textFillStyle","labelMaxLen","WIDTH","maxPolygonPoint","HEIGHT","crossX","crossY","crossStroke","showCross","dataset","isMagnifierVisible","magnifierPosition","remmber","mouse","remmberOrigin","createType","None","ctrlIndex","image","Image","IMAGE_ORIGIN_WIDTH","IMAGE_WIDTH","IMAGE_ORIGIN_HEIGHT","IMAGE_HEIGHT","originX","originY","scaleStep","scrollZoom","timer","dblTouch","dblTouchStore","alpha","focusMode","scaleTouchStore","isTouch2","isMobile","navigator","userAgent","includes","labelUp","isCtrlKey","ctrlCode","gridMenuEnable","gridSelectedFillStyle","position","handleLoad","bind","handleContextmenu","handleMousewheel","handleMouseDown","handleMouseMove","handleMouseUp","handleDblclick","handleKeyup","handleKeydown","container","document","querySelector","HTMLCanvasElement","canvas","offScreen","createElement","initSetting","initEvents","setImage","console","warn","min","max","createMagnifierCanvas","magnifierCanvas","magnifierCtx","getContext","willReadFrequently","style","pointerEvents","zIndex","border","borderRadius","body","appendChild","createMagnifier","updateMagnifier","magnifierSize","dpr","window","devicePixelRatio","clearRect","mx","my","left","concat","top","originImageData","getImageDataFromCanvas","areaImageData","createImageData","count","k","putImageData","strokeRect","destroyMagnifier","remove","undefined","context","getImageData","mergeEvent","e","mouseX","mouseY","mouseCX","mouseCY","touches","clientX","clientY","target","getBoundingClientRect","top_1","round","_e","_f","clientX1","_g","clientY1","abs","offsetX","offsetY","__assign","fitZoom","preventDefault","stopPropagation","setScale","deltaY","scale","buttons","ctrls","activeShape","ctrlsData","findIndex","isPointInCircle","isInBackground","nx","ny","log","hitOnShape","hitShapeIndex_1","hitShape","_h","pt","sort","a","b","newShape","curPoint","sp","update","rowCol","prompt","_j","split","test","Number","center","atan2","PI","_k","_l","_m","_o","a0","b0","_p","a1","b1","newPoint","newRadius","_q","ux","uy","_r","noLimit","_s","t1","tar","_t","r","sqrt","pow","which","touch0","touch1","cur","Date","now","pop","canPolygon","canLine","canPolygonByMaxPoints","canLineByTwoPoints","gridRects","rect","isPointInRect","thisIndex","code","activeElement","key","isPolygonAtMaxPoints","isLineAtTwoPoints","deleteByIndex","crossOrigin","userSelect","ctx","clientWidth","clientHeight","offScreenCtx","addEventListener","source","complete","setData","setTimeout","initdata","toString","mousePoint","hitShapeIndex","hide","isPointInPolygon","isPointInLine","point","save","translate","beginPath","moveTo","lineTo","closePath","fill","areaData","restore","stroke","drawRect","sub","isSelected","selectedFillStyle","rotate","fillRect","drawLabel","drawPolygon","lineJoin","shouldClose","drawDot","arc","drawCirle","drawEllipse","scaledRadiusX","scaledRadiusY","ellipse","drawLine","shouldEnd","drawGrid","drawBrushPath","globalCompositeOperation","lineCap","drawEraserPath","clearBrush","newDateset","filter","drawCtrl","color","drawCtrlList","isHideLabel","isLabelUp","currLineWidth","font","newText","text","measureText","parseInt","labelWidth","textPaddingLeft","labelHeight","textPaddingTop","toleft","toTop","toTop2","isup","fillText","cancelAnimationFrame","requestAnimationFrame","renderList","BrushAndErasers","NormalShapes","drawImage","num","deleteByUuid","calcStep","flag","byMouse","pure","imageMin","imageOriginMax","realToLeft","realToRight","setFocusMode","destroy","removeEventListener","resize","removeAttribute"],"mappings":";;;;;;q+BAMA,ICiBKA,EDjBLA,EAmCI,SAAYC,EAAiBC,GAjCtBC,KAAAC,MAAgB,GAIhBD,KAAAE,KAAc,GAgBdF,KAAAG,QAAkB,EAElBH,KAAAI,UAAoB,EAEpBJ,KAAAK,UAAoB,EAIpBL,KAAAM,gBEjCT,IAFA,IAAMC,EAAW,GACXC,EAAY,mBACTC,EAAI,EAAGA,EAAI,GAAIA,IAAK,CAC3B,IAAMC,EAAIC,KAAKC,MAAsB,GAAhBD,KAAKE,UAC1BN,EAAEE,GAAKD,EAAUM,MAAMJ,EAAGA,EAAI,EAChC,CACAH,EAAE,IAAM,IACR,IAAMQ,EAAa,EAARR,EAAE,IAAa,EAI1B,OAHAA,EAAE,IAAMC,EAAUM,MAAMC,EAAGA,EAAI,GAC/BR,EAAE,GAAKA,EAAE,IAAMA,EAAE,IAAMA,EAAE,IAAM,IAClBA,EAAES,KAAK,GAEtB,CFuB0BC,GAMlBjB,KAAKD,MAAQA,EACbmB,OAAOC,OAA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|
1
|
+
/*!
|
|
2
|
+
* zkqh-canvas-select-one v2.32.3
|
|
3
|
+
* 一个用于图片标注的javascript库,基于canvas,简单轻量,支持矩形、多边形、点、折线、圆形、网格、画笔、橡皮擦
|
|
4
|
+
* (c) 2025 heylight
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).CanvasSelect=e()}(this,function(){"use strict";var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};function e(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i=function(){return i=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var a in e=arguments[i])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},i.apply(this,arguments)};function s(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var s,a,o=i.call(t),n=[];try{for(;(void 0===e||e-- >0)&&!(s=o.next()).done;)n.push(s.value)}catch(t){a={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(a)throw a.error}}return n}"function"==typeof SuppressedError&&SuppressedError;var a,o=function(t,e){this.label="",this.coor=[],this.active=!1,this.creating=!1,this.dragging=!1,this.uuid=function(){for(var t=[],e="0123456789abcdef",i=0;i<36;i++){var s=Math.floor(16*Math.random());t[i]=e.slice(s,s+1)}t[14]="4";var a=3&t[19]|8;return t[19]=e.slice(a,a+1),t[8]=t[13]=t[18]=t[23]="-",t.join("")}(),this.index=e,Object.assign(this,t)},n=function(t){function i(e,i,s){var a,o,n,r,h=t.call(this,e,i)||this;return h.type=1,h.rotation=0,h.lineWidth=null!==(a=e.lineWidth)&&void 0!==a?a:s.lineWidth,h.fillStyle=null!==(o=e.fillStyle)&&void 0!==o?o:s.fillStyle,h.strokeStyle=null!==(n=e.strokeStyle)&&void 0!==n?n:s.strokeStyle,h.showRotation=null!==(r=e.showRotation)&&void 0!==r?r:s.showRotation,h}return e(i,t),Object.defineProperty(i.prototype,"ctrlsData",{get:function(){var t=this,e=s(this.coor,2),i=s(e[0],2),a=i[0],o=i[1],n=s(e[1],2),r=n[0],h=n[1],c=(a+r)/2,l=(o+h)/2,d=r-a,u=h-o,v=[[a,o],[a+d/2,o],[r,o],[r,o+u/2],[r,h],[a+d/2,h],[a,h],[a,o+u/2]];return this.showRotation&&v.push([c,o-20,"green"]),0===this.rotation?v:v.map(function(e){var i=s(e,2),a=i[0],o=i[1],n=a-c,r=o-l,h=n*Math.cos(t.rotation)-r*Math.sin(t.rotation),d=n*Math.sin(t.rotation)+r*Math.cos(t.rotation);return[h+c,d+l]})},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"center",{get:function(){var t=s(this.coor,2),e=s(t[0],2),i=e[0],a=e[1],o=s(t[1],2);return[(i+o[0])/2,(a+o[1])/2]},enumerable:!1,configurable:!0}),i}(o),r=function(t){function i(e,i,s){var a,o,n=t.call(this,e,i)||this;return n.type=2,n.fillStyle=null!==(a=e.fillStyle)&&void 0!==a?a:s.fillStyle,n.strokeStyle=null!==(o=e.strokeStyle)&&void 0!==o?o:s.strokeStyle,n}return e(i,t),Object.defineProperty(i.prototype,"ctrlsData",{get:function(){return this.coor.length>2?this.coor:[]},enumerable:!1,configurable:!0}),i}(o),h=function(t){function i(e,i,s){var a,o,n=t.call(this,e,i)||this;return n.type=3,n.fillStyle=null!==(a=e.fillStyle)&&void 0!==a?a:s.fillStyle,n.strokeStyle=null!==(o=e.strokeStyle)&&void 0!==o?o:s.strokeStyle,n}return e(i,t),i}(o),c=function(){function t(){this._eventTree={}}return t.prototype.on=function(t,e){var i=this._eventTree[t];Array.isArray(i)?i.push(e):this._eventTree[t]=[e]},t.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var a=this._eventTree[t];Array.isArray(a)&&a.forEach(function(t){return t.apply(void 0,function(t,e,i){if(i||2===arguments.length)for(var s,a=0,o=e.length;a<o;a++)!s&&a in e||(s||(s=Array.prototype.slice.call(e,0,a)),s[a]=e[a]);return t.concat(s||Array.prototype.slice.call(e))}([],s(e),!1))})},t.prototype.off=function(t,e){var i=this._eventTree[t],s=i.find(function(t){return t===e});Array.isArray(i)&&s&&i.splice(s,1)},t}(),l=function(t){function i(e,i,s){var a,o=t.call(this,e,i)||this;return o.type=4,o.strokeStyle=null!==(a=e.strokeStyle)&&void 0!==a?a:s.strokeStyle,o}return e(i,t),Object.defineProperty(i.prototype,"ctrlsData",{get:function(){return this.coor.length>1?this.coor:[]},enumerable:!1,configurable:!0}),i}(o),d=function(t){function i(e,i,s){var a,o,n=t.call(this,e,i)||this;return n.type=5,n.radius=0,n.radius=e.radius||n.radius,n.fillStyle=null!==(a=e.fillStyle)&&void 0!==a?a:s.fillStyle,n.strokeStyle=null!==(o=e.strokeStyle)&&void 0!==o?o:s.strokeStyle,n}return e(i,t),Object.defineProperty(i.prototype,"ctrlsData",{get:function(){var t=s(this.coor,2),e=t[0],i=t[1];return[[e,i-this.radius],[e+this.radius,i],[e,i+this.radius],[e-this.radius,i]]},enumerable:!1,configurable:!0}),i}(o),u=function(t){function i(e,i,s){var a,o,n=t.call(this,e,i)||this;return n.type=6,n.row=1,n.col=1,n.selected=[],n.row=e.row>0?e.row:n.row,n.col=e.col>0?e.col:n.col,n.selected=Array.isArray(e.selected)?e.selected:[],n.fillStyle=null!==(a=e.fillStyle)&&void 0!==a?a:s.fillStyle,n.strokeStyle=null!==(o=e.strokeStyle)&&void 0!==o?o:s.strokeStyle,n}return e(i,t),Object.defineProperty(i.prototype,"ctrlsData",{get:function(){var t=s(this.coor,2),e=s(t[0],2),i=e[0],a=e[1],o=s(t[1],2),n=o[0],r=o[1];return[[i,a],[i+(n-i)/2,a],[n,a],[n,a+(r-a)/2],[n,r],[i+(n-i)/2,r],[i,r],[i,a+(r-a)/2]]},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gridRects",{get:function(){for(var t=s(this.coor,2),e=s(t[0],2),i=e[0],a=e[1],o=s(t[1],2),r=o[0],h=o[1],c=this,l=c.row,d=c.col,u=c.strokeStyle,v=c.fillStyle,f=c.active,p=c.creating,y=c.lineWidth,g=(r-i)/this.col,S=(h-a)/this.row,I=[],m=0;m<l;m++)for(var b=0;b<d;b++){var x=[i+b*g,a+m*S],M=new n({coor:[x,[x[0]+g,x[1]+S]],strokeStyle:u,fillStyle:v,active:f,creating:p,lineWidth:y},m*d+b,{});I.push(M)}return I},enumerable:!1,configurable:!0}),i}(o),v="2.32.3",f=function(t){function i(e,i,s){var a,o,n=t.call(this,e,i)||this;return n.type=7,n.coor=[],n.brushSize=null!==(a=e.brushSize)&&void 0!==a?a:s.brushSize,n.brushStokeStyle=null!==(o=e.brushStokeStyle)&&void 0!==o?o:s.brushStokeStyle,n.coor=e.coor,n}return e(i,t),i}(o),p=function(t){function i(e,i,s){var a,o=t.call(this,e,i)||this;return o.type=8,o.coor=[],o.eraserSize=null!==(a=e.eraserSize)&&void 0!==a?a:s.eraserSize,o.coor=e.coor,o}return e(i,t),i}(o),y=function(t){function i(e,i,s){var a,o,n,r=t.call(this,e,i)||this;return r.type=9,r.radiusX=0,r.radiusY=0,r.rotation=0,r.radiusX=e.radiusX||r.radiusX,r.radiusY=e.radiusY||r.radiusY,r.rotation=e.rotation||r.rotation,r.fillStyle=null!==(a=e.fillStyle)&&void 0!==a?a:s.fillStyle,r.strokeStyle=null!==(o=e.strokeStyle)&&void 0!==o?o:s.strokeStyle,r.lineWidth=null!==(n=e.lineWidth)&&void 0!==n?n:s.lineWidth,r}return e(i,t),Object.defineProperty(i.prototype,"ctrlsData",{get:function(){var t=s(this.coor,2),e=t[0],i=t[1];return[[e,i-this.radiusY],[e+this.radiusX,i],[e,i+this.radiusY],[e-this.radiusX,i]]},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"boundingBox",{get:function(){var t=s(this.coor,2),e=t[0],i=t[1];return[[e-this.radiusX,i-this.radiusY],[e+this.radiusX,i+this.radiusY]]},enumerable:!1,configurable:!0}),i.prototype.isPointInEllipse=function(t,e){var i=s(this.coor,2),a=i[0],o=i[1];if(0!==this.rotation){var n,r,h=Math.cos(-this.rotation),c=Math.sin(-this.rotation),l=(n=t-a)*h-(r=e-o)*c,d=n*c+r*h;return l*l/(this.radiusX*this.radiusX)+d*d/(this.radiusY*this.radiusY)<=1}return(n=(t-a)/this.radiusX)*n+(r=(e-o)/this.radiusY)*r<=1},i}(o);return function(t){t[t.None=0]="None",t[t.Rect=1]="Rect",t[t.Polygon=2]="Polygon",t[t.Dot=3]="Dot",t[t.Line=4]="Line",t[t.Circle=5]="Circle",t[t.Grid=6]="Grid",t[t.Brush=7]="Brush",t[t.Eraser=8]="Eraser",t[t.Ellipse=9]="Ellipse"}(a||(a={})),function(t){function o(e,i){var s=t.call(this)||this;s.version=v,s.lock=!1,s.readonly=!1,s.MIN_WIDTH=10,s.MIN_HEIGHT=10,s.MIN_RADIUS=5,s.MAX_POLYGON_POINTS=6,s.strokeStyle="#0f0",s.fillStyle="rgba(0, 0, 255, 0.1)",s.lineWidth=1,s.activeStrokeStyle="#f00",s.activeFillStyle="rgba(0, 0, 255, 0.1)",s.ctrlStrokeStyle="#000",s.ctrlFillStyle="#fff",s.ctrlRadius=3,s.hideLabel=!1,s.labelFillStyle="#fff",s.labelFont="10px sans-serif",s.textFillStyle="#000",s.labelMaxLen=10,s.WIDTH=0,s.maxPolygonPoint=6,s.HEIGHT=0,s.crossX=new l({},0,{}),s.crossY=new l({},1,{}),s.crossStroke="#ff0",s.showCross=!1,s.showRotation=!1,s.dataset=[],s.isMagnifierVisible=!1,s.magnifierPosition="auto",s.remmber=[],s.mouse=[0,0],s.remmberOrigin=[0,0],s.createType=a.None,s.ctrlIndex=-1,s.image=new Image,s.IMAGE_ORIGIN_WIDTH=0,s.IMAGE_WIDTH=0,s.IMAGE_ORIGIN_HEIGHT=0,s.IMAGE_HEIGHT=0,s.originX=0,s.originY=0,s.scaleStep=0,s.scrollZoom=!0,s.timer=null,s.dblTouch=300,s.dblTouchStore=0,s.alpha=!0,s.focusMode=!1,s.scaleTouchStore=0,s.isTouch2=!1,s.isMobile=navigator.userAgent.includes("Mobile"),s.labelUp=!1,s.isCtrlKey=!1,s.ctrlCode="ControlLeft",s.gridMenuEnable=!0,s.gridSelectedFillStyle="rgba(255, 255, 0, 0.6)",s.brushSize=20,s.brushStokeStyle="#f00",s.eraserSize=20,s.position=[0,0],s.handleLoad=s.handleLoad.bind(s),s.handleContextmenu=s.handleContextmenu.bind(s),s.handleMousewheel=s.handleMousewheel.bind(s),s.handleMouseDown=s.handleMouseDown.bind(s),s.handleMouseMove=s.handleMouseMove.bind(s),s.handleMouseUp=s.handleMouseUp.bind(s),s.handleDblclick=s.handleDblclick.bind(s),s.handleKeyup=s.handleKeyup.bind(s),s.handleKeydown=s.handleKeydown.bind(s);var o="string"==typeof e?document.querySelector(e):e;return o instanceof HTMLCanvasElement?(s.canvas=o,s.offScreen=document.createElement("canvas"),s.initSetting(),s.initEvents(),i&&s.setImage(i)):console.warn("HTMLCanvasElement is required!"),s.crossX.strokeStyle=s.crossStroke,s.crossY.strokeStyle=s.crossStroke,s}return e(o,t),Object.defineProperty(o.prototype,"activeShape",{get:function(){return this.dataset.find(function(t){return t.active})||{}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"scale",{get:function(){return this.IMAGE_ORIGIN_WIDTH&&this.IMAGE_WIDTH?this.IMAGE_WIDTH/this.IMAGE_ORIGIN_WIDTH:1},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"imageMin",{get:function(){return Math.min(this.IMAGE_WIDTH,this.IMAGE_HEIGHT)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"imageOriginMax",{get:function(){return Math.max(this.IMAGE_ORIGIN_WIDTH,this.IMAGE_ORIGIN_HEIGHT)},enumerable:!1,configurable:!0}),o.prototype.createMagnifierCanvas=function(){this.isMagnifierVisible&&(this.magnifierCanvas=this.magnifierCanvas||document.createElement("canvas"),this.magnifierCtx=this.magnifierCanvas&&this.magnifierCanvas.getContext("2d",{willReadFrequently:!0}),this.magnifierCanvas.style.position="fixed",this.magnifierCanvas.style.pointerEvents="none",this.magnifierCanvas.style.zIndex="1000",this.magnifierCanvas.style.border="1px solid black",this.magnifierCanvas.style.borderRadius="50%",this.magnifierCanvas.style.width="100px",this.magnifierCanvas.style.height="100px",document.body.appendChild(this.magnifierCanvas))},o.prototype.createMagnifier=function(t,e){this.magnifierCanvas?this.updateMagnifier(t,e):this.createMagnifierCanvas()},o.prototype.updateMagnifier=function(t,e){var i,a;if(this.canvas&&this.magnifierCanvas&&this.magnifierCtx){var o=100,n=window.devicePixelRatio||1;if(this.magnifierCanvas.width=o,this.magnifierCanvas.height=o,this.magnifierCtx.clearRect(0,0,o,o),this.magnifierPosition&&2===this.magnifierPosition.length){var r=s(this.magnifierPosition,2),h=r[0],c=r[1];this.magnifierCanvas.style.left="".concat(h,"px"),this.magnifierCanvas.style.top="".concat(c,"px")}else this.magnifierCanvas.style.left="".concat(t+10,"px"),this.magnifierCanvas.style.top="".concat(e+10,"px");var l=this.getImageDataFromCanvas(this.canvas,[t*n-50,e*n-50,o,o]),d=null===(i=this.magnifierCanvas.getContext("2d",{willReadFrequently:!0}))||void 0===i?void 0:i.createImageData(this.magnifierCanvas.width,this.magnifierCanvas.height);if(d&&l){for(var u=0,v=0;v<o;v+=1)for(var f=0;f<o;f+=1){for(var p=v;p<v+1;p++)for(var y=f;y<f+1;y++){var g=4*(p*o+y);d.data[g]=l.data[u],d.data[g+1]=l.data[u+1],d.data[g+2]=l.data[u+2],d.data[g+3]=l.data[u+3]}u+=4}null===(a=this.magnifierCanvas.getContext("2d",{willReadFrequently:!0}))||void 0===a||a.putImageData(d,0,0),this.magnifierCtx.strokeStyle="rgba(0, 0, 0, 0.5)",this.magnifierCtx.lineWidth=2,this.magnifierCtx.strokeRect(0,0,o,o)}}},o.prototype.destroyMagnifier=function(){this.magnifierCanvas&&(this.magnifierCanvas.remove(),this.magnifierCanvas=void 0,this.magnifierCtx=void 0)},o.prototype.getImageDataFromCanvas=function(t,e){var i=s(e,4),a=i[0],o=i[1],n=i[2],r=i[3],h=t.getContext("2d",{willReadFrequently:!0});return null==h?void 0:h.getImageData(a,o,n,r)},o.prototype.mergeEvent=function(t){var e,s,a=0,o=0,n=0,r=0;if(this.isMobile&&t.touches){var h=t.touches[0],c=h.clientX,l=h.clientY,d=t.target.getBoundingClientRect(),u=d.left,v=d.top;if(a=Math.round(c-u),o=Math.round(l-v),2===(null===(e=t.touches)||void 0===e?void 0:e.length)){var f=t.touches[1]||{},p=f.clientX,y=void 0===p?0:p,g=f.clientY,S=void 0===g?0:g;n=Math.round(Math.abs((y-c)/2+c)-u),r=Math.round(Math.abs((S-l)/2+l)-v)}else 1===(null===(s=t.touches)||void 0===s?void 0:s.length)&&(n=Math.round(c-u),r=Math.round(l-v))}else a=t.offsetX,o=t.offsetY;return i(i({},t),{mouseX:a,mouseY:o,mouseCX:n,mouseCY:r})},o.prototype.handleLoad=function(){this.emit("load",this.image.src),this.IMAGE_ORIGIN_WIDTH=this.IMAGE_WIDTH=this.image.width,this.IMAGE_ORIGIN_HEIGHT=this.IMAGE_HEIGHT=this.image.height,this.fitZoom()},o.prototype.handleContextmenu=function(t){t.preventDefault(),this.lock},o.prototype.handleMousewheel=function(t){if(t.preventDefault(),t.stopPropagation(),!this.lock&&this.scrollZoom){var e=this.mergeEvent(t),i=e.mouseX,s=e.mouseY;this.mouse=[i,s],this.setScale(t.deltaY<0,!0)}},o.prototype.handleMouseDown=function(t){var e,i,o,c=this;if(t.stopPropagation(),!this.lock){var v=this.mergeEvent(t),y=v.mouseX,g=v.mouseY,S=v.mouseCX,I=v.mouseCY,m=Math.round(y/this.scale),b=Math.round(g/this.scale);if(this.mouse=this.isMobile&&2===(null===(e=t.touches)||void 0===e?void 0:e.length)?[S,I]:[y,g],this.remmberOrigin=[y-this.originX,g-this.originY],!this.isMobile&&1===t.buttons||this.isMobile&&1===(null===(i=t.touches)||void 0===i?void 0:i.length)){var x=this.activeShape.ctrlsData||[];if(this.ctrlIndex=x.findIndex(function(t){return c.isPointInCircle(c.mouse,t,c.ctrlRadius)}),this.ctrlIndex>-1&&!this.readonly){var M=s(x[this.ctrlIndex],2),E=M[0],H=M[1];this.activeShape.type===a.Polygon&&this.activeShape.coor.length>2&&0===this.ctrlIndex&&this.handleDblclick(t),this.remmber=[[m-E,b-H]]}else if(this.isInBackground(t)){var T=Math.round(m-this.originX/this.scale),w=Math.round(b-this.originY/this.scale);if(this.activeShape.creating&&!this.readonly){if([a.Polygon,a.Line].includes(this.activeShape.type)){var G=s(this.activeShape.coor[this.activeShape.coor.length-1],2),k=G[0],C=G[1];k!==m&&C!==b&&(this.activeShape.coor.push([T,w]),this.activeShape.type===a.Polygon&&this.MAX_POLYGON_POINTS&&this.activeShape.coor.length>=this.MAX_POLYGON_POINTS&&(console.log("@13131"),this.handleDblclick(t)),this.activeShape.type===a.Line&&this.activeShape.coor.length>=2&&this.handleDblclick(t))}}else if(this.createType===a.None||this.readonly||this.isCtrlKey){var _=s(this.hitOnShape(this.mouse),2),D=_[0],P=_[1];if(D>-1&&P){if(P.dragging=!0,this.dataset.forEach(function(t,e){return t.active=e===D}),this.dataset.splice(D,1),this.dataset.push(P),!this.readonly)if(this.remmber=[],[a.Dot,a.Circle].includes(P.type)){var W=s(P.coor,2);k=W[0],C=W[1];this.remmber=[[m-k,b-C]]}else P.coor.forEach(function(t){c.remmber.push([m-t[0],b-t[1]])});this.emit("select",P)}else this.activeShape.active=!1,this.dataset.sort(function(t,e){return t.index-e.index}),this.emit("select",null)}else{var R=void 0,O=[T,w];switch(this.createType){case a.Rect:(R=new n({coor:[O,O]},this.dataset.length,this)).creating=!0;break;case a.Polygon:(R=new r({coor:[O]},this.dataset.length,this)).creating=!0;break;case a.Dot:R=new h({coor:O},this.dataset.length,this),this.emit("add",R);break;case a.Line:(R=new l({coor:[O]},this.dataset.length,this)).creating=!0;break;case a.Circle:R=new d({coor:O},this.dataset.length,this),console.log(R),R.creating=!0;break;case a.Grid:(R=new u({coor:[O,O]},this.dataset.length,this)).creating=!0;break;case a.Brush:(R=new f({coor:[O]},this.dataset.length,this)).creating=!0;break;case a.Eraser:(R=new p({coor:[O]},this.dataset.length,this)).creating=!0}R&&(this.dataset.forEach(function(t){t.active=!1}),R.active=!0,this.dataset.push(R))}this.update()}}else if(!this.isMobile&&2===t.buttons||this.isMobile&&3===(null===(o=t.touches)||void 0===o?void 0:o.length)&&!this.readonly){if([a.Grid].includes(this.activeShape.type)&&this.gridMenuEnable){var L=prompt("x 行 y 列 x,y",[this.activeShape.row,this.activeShape.col].join(","));if("string"==typeof L){var A=s(L.split(","),2),N=A[0],X=A[1];/^[1-9]\d*$/.test(N)&&/^[1-9]\d*$/.test(X)&&(this.activeShape.row=Number(N),this.activeShape.col=Number(X),this.update())}}this.emit("contextmenu",t)}}},o.prototype.handleMouseMove=function(t){var e,i,o,n;if(t.stopPropagation(),!this.lock){var r=this.mergeEvent(t),h=r.mouseX,c=r.mouseY,l=r.mouseCX,d=r.mouseCY,u=Math.round(h/this.scale),v=Math.round(c/this.scale);!this.isCtrlKey&&this.isInBackground(t)?(this.crossX.coor=[[u-this.originX/this.scale,0],[u-this.originX/this.scale,this.image.height]],this.crossY.coor=[[0,v-this.originY/this.scale],[this.image.width,v-this.originY/this.scale]]):(this.crossX.coor=[],this.crossY.coor=[]),this.mouse=this.isMobile&&2===(null===(e=t.touches)||void 0===e?void 0:e.length)?[l,d]:[h,c];var f=Math.round(u-this.originX/this.scale),p=Math.round(v-this.originY/this.scale);if(this.position=[f,p],(!this.isMobile&&1===t.buttons||this.isMobile&&1===(null===(i=t.touches)||void 0===i?void 0:i.length))&&this.activeShape.type){if(this.ctrlIndex>-1&&this.remmber.length&&(this.isInBackground(t)||this.activeShape.type===a.Circle)){var y=s(this.remmber,1),g=s(y[0],2),S=g[0],I=g[1];if([a.Rect,a.Grid].includes(this.activeShape.type))if(8===this.ctrlIndex){var m=s(this.activeShape.center,2),b=u-S-m[0],x=v-I-m[1];this.activeShape.rotation=Math.atan2(x,b)+Math.PI/2}else{var M=s(this.activeShape.coor,2),E=s(M[0],2),H=E[0],T=E[1],w=s(M[1],2),G=w[0],k=w[1],C=[];switch(this.ctrlIndex){case 0:C=[[u-S,v-I],[G,k]];break;case 1:C=[[H,v-I],[G,k]];break;case 2:C=[[H,v-I],[u-S,k]];break;case 3:C=[[H,T],[u-S,k]];break;case 4:C=[[H,T],[u-S,v-I]];break;case 5:C=[[H,T],[G,v-I]];break;case 6:C=[[u-S,T],[G,v-I]];break;case 7:C=[[u-S,T],[G,k]]}var _=s(C,2),D=s(_[0],2),P=D[0],W=D[1],R=s(_[1],2),O=R[0],L=R[1];(P<0||O<0||W<0||L<0||O>this.IMAGE_ORIGIN_WIDTH||L>this.IMAGE_ORIGIN_HEIGHT)&&(P<0&&(P=0),O<0&&(O=0),W<0&&(W=0),L<0&&(L=0),O>this.IMAGE_ORIGIN_WIDTH&&(O=this.IMAGE_ORIGIN_WIDTH),L>this.IMAGE_ORIGIN_HEIGHT&&(L=this.IMAGE_ORIGIN_HEIGHT)),O-P>=this.MIN_WIDTH&&L-W>=this.MIN_HEIGHT?this.activeShape.coor=[[P,W],[O,L]]:this.emit("warn","Width cannot be less than ".concat(this.MIN_WIDTH,",Height cannot be less than").concat(this.MIN_HEIGHT,"。"))}else if([a.Polygon,a.Line].includes(this.activeShape.type)){var A=[f,p];this.activeShape.coor.splice(this.ctrlIndex,1,A)}else if(this.activeShape.type===a.Circle){var N=Math.round(u-this.originX/this.scale)-this.activeShape.coor[0];N>=this.MIN_RADIUS&&(this.activeShape.radius=N)}if(this.isMagnifierVisible){var X=s(this.isMobile?[l,d]:[h,c],2),Y=X[0],F=X[1];this.createMagnifier(Y,F)}}else if(this.activeShape.dragging&&!this.readonly){if(this.isMagnifierVisible&&3===this.activeShape.type){var B=s(this.isMobile?[l,d]:[h,c],2);Y=B[0],F=B[1];this.createMagnifier(Y,F)}C=[];var j=!0,z=this.IMAGE_ORIGIN_WIDTH||this.WIDTH,K=this.IMAGE_ORIGIN_HEIGHT||this.HEIGHT;if([a.Dot,a.Circle].includes(this.activeShape.type)){var U=s(this.remmber[0],2),q=U[0];I=v-U[1];((S=u-q)<0||S>z||I<0||I>K)&&(j=!1),C=[S,I]}else for(var J=0;J<this.activeShape.coor.length;J++){var V=this.remmber[J];S=u-V[0],I=v-V[1];(S<0||S>z||I<0||I>K)&&(j=!1),C.push([S,I])}j&&(this.activeShape.coor=C)}else if(this.activeShape.creating&&this.isInBackground(t))if([a.Rect,a.Grid].includes(this.activeShape.type))this.activeShape.coor.splice(1,1,[f,p]);else if(this.activeShape.type===a.Circle){var Z=s(this.activeShape.coor,2),$=(H=Z[0],T=Z[1],Math.sqrt(Math.pow(H-f,2)+Math.pow(T-p,2)));this.activeShape.radius=$}else[a.Brush,a.Eraser].includes(this.activeShape.type)&&this.activeShape.coor.push([f,p]);this.update()}else if([a.Polygon,a.Line].includes(this.activeShape.type)&&this.activeShape.creating)this.update();else if(!this.isMobile&&2===t.buttons&&3===t.which||this.isMobile&&1===(null===(o=t.touches)||void 0===o?void 0:o.length)&&!this.isTouch2)this.originX=Math.round(h-this.remmberOrigin[0]),this.originY=Math.round(c-this.remmberOrigin[1]),this.update();else if(this.isMobile&&2===(null===(n=t.touches)||void 0===n?void 0:n.length)){this.isTouch2=!0;var Q=t.touches[0],tt=t.touches[1],et=this.scaleTouchStore;this.scaleTouchStore=Math.abs((tt.clientX-Q.clientX)*(tt.clientY-Q.clientY)),this.setScale(this.scaleTouchStore>et,!0)}else this.isCtrlKey||this.update()}},o.prototype.handleMouseUp=function(t){var e;if(t.stopPropagation(),!this.lock){if(this.destroyMagnifier(),this.isMobile){if(0===(null===(e=t.touches)||void 0===e?void 0:e.length)&&(this.isTouch2=!1),Date.now()-this.dblTouchStore<this.dblTouch)return void this.handleDblclick(t);this.dblTouchStore=Date.now()}if(this.remmber=[],this.activeShape.type!==a.None&&!this.isCtrlKey&&(this.activeShape.dragging=!1,this.activeShape.creating)){if([a.Rect,a.Grid].includes(this.activeShape.type)){var i=s(this.activeShape.coor,2),o=s(i[0],2),n=o[0],r=o[1],h=s(i[1],2),c=h[0],l=h[1];Math.abs(n-c)<this.MIN_WIDTH||Math.abs(r-l)<this.MIN_HEIGHT?(this.dataset.pop(),this.emit("warn","Width cannot be less than ".concat(this.MIN_WIDTH,",Height cannot be less than ").concat(this.MIN_HEIGHT))):(this.activeShape.coor=[[Math.min(n,c),Math.min(r,l)],[Math.max(n,c),Math.max(r,l)]],this.activeShape.creating=!1,this.emit("add",this.activeShape))}else this.activeShape.type===a.Circle?this.activeShape.radius<this.MIN_RADIUS?(this.dataset.pop(),this.emit("warn","Radius cannot be less than ".concat(this.MIN_WIDTH))):(this.activeShape.creating=!1,this.emit("add",this.activeShape)):[a.Brush,a.Eraser].includes(this.activeShape.type)&&(this.activeShape.creating=!1,this.emit("add",this.activeShape));this.update()}}},o.prototype.handleDblclick=function(t){var e=this;if(t.stopPropagation(),!this.lock)if([a.Polygon,a.Line].includes(this.activeShape.type)){var i=this.activeShape.type===a.Polygon&&this.activeShape.coor.length>2,s=this.activeShape.type===a.Line&&this.activeShape.coor.length>1,o=this.activeShape.type===a.Polygon&&this.activeShape.coor.length>=this.MAX_POLYGON_POINTS,n=this.activeShape.type===a.Line&&this.activeShape.coor.length>=2;(i||s||o||n)&&(this.emit("add",this.activeShape),this.activeShape.creating=!1,this.update())}else[a.Grid].includes(this.activeShape.type)&&this.activeShape.active&&(this.activeShape.gridRects.forEach(function(t){if(e.isPointInRect(e.mouse,t.coor)){var i=e.activeShape.selected.findIndex(function(e){return t.index===e});i>-1?e.activeShape.selected.splice(i,1):e.activeShape.selected.push(t.index)}}),this.update())},o.prototype.handleKeydown=function(t){t.code===this.ctrlCode&&(this.isCtrlKey=!0)},o.prototype.handleKeyup=function(t){if(t.code===this.ctrlCode&&(this.isCtrlKey=!1),!this.lock&&document.activeElement===document.body&&!this.readonly&&this.activeShape.type)if([a.Polygon,a.Line].includes(this.activeShape.type)&&"Escape"===t.key){var e=this.activeShape.type===a.Polygon&&this.activeShape.coor.length>=this.MAX_POLYGON_POINTS,i=this.activeShape.type===a.Line&&this.activeShape.coor.length>=2;this.activeShape.coor.length>1&&this.activeShape.creating&&!e&&!i?this.activeShape.coor.pop():this.deleteByIndex(this.activeShape.index),this.update()}else"Backspace"===t.key&&this.deleteByIndex(this.activeShape.index)},o.prototype.initSetting=function(){var t;if(this.canvas&&this.offScreen){var e=window.devicePixelRatio||1;this.image.crossOrigin="anonymous",this.canvas.style.userSelect="none",this.ctx=this.ctx||this.canvas.getContext("2d",{alpha:this.alpha}),this.WIDTH=this.canvas.clientWidth,this.HEIGHT=Math.round(this.canvas.clientHeight),this.canvas.width=this.WIDTH*e,this.canvas.height=this.HEIGHT*e,this.canvas.style.width=this.WIDTH+"px",this.canvas.style.height=this.HEIGHT+"px",this.offScreen.width=this.WIDTH,this.offScreen.height=this.HEIGHT,this.offScreenCtx=this.offScreenCtx||this.offScreen.getContext("2d",{willReadFrequently:!0}),null===(t=this.ctx)||void 0===t||t.scale(e,e)}},o.prototype.initEvents=function(){this.canvas&&(this.image.addEventListener("load",this.handleLoad),this.canvas.addEventListener("touchstart",this.handleMouseDown),this.canvas.addEventListener("touchmove",this.handleMouseMove),this.canvas.addEventListener("touchend",this.handleMouseUp),this.canvas.addEventListener("contextmenu",this.handleContextmenu),this.canvas.addEventListener("mousewheel",this.handleMousewheel),this.canvas.addEventListener("wheel",this.handleMousewheel),this.canvas.addEventListener("mousedown",this.handleMouseDown),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseup",this.handleMouseUp),this.canvas.addEventListener("dblclick",this.handleDblclick),document.body.addEventListener("keydown",this.handleKeydown,!0),document.body.addEventListener("keyup",this.handleKeyup,!0))},o.prototype.setImage=function(t){"string"==typeof t?this.image.src=t:(this.image=t,this.image.crossOrigin="anonymous",this.image.complete?this.handleLoad():this.image.addEventListener("load",this.handleLoad))},o.prototype.setData=function(t){var e=this;setTimeout(function(){var i=[];t.forEach(function(t,s){if(Object.prototype.toString.call(t).includes("Object")){var o=void 0;switch(t.type){case a.Rect:o=new n(t,s,e);break;case a.Polygon:o=new r(t,s,e);break;case a.Dot:o=new h(t,s,e);break;case a.Line:o=new l(t,s,e);break;case a.Circle:o=new d(t,s,e);break;case a.Grid:o=new u(t,s,e);break;case a.Brush:o=new f(t,s,e);break;case a.Eraser:o=new p(t,s,e);break;case a.Ellipse:o=new y(t,s,e);break;default:console.warn("Invalid shape",t)}[a.Rect,a.Polygon,a.Dot,a.Line,a.Circle,a.Grid,a.Brush,a.Eraser,a.Ellipse].includes(t.type)&&o&&i.push(o)}else console.warn("Shape must be an enumerable Object.",t)}),e.dataset=i,e.update()})},o.prototype.hitOnShape=function(t){for(var e,i=-1,s=this.dataset.length-1;s>-1;s--){var o=this.dataset[s];if(!o.hide&&(o.type===a.Dot&&this.isPointInCircle(t,o.coor,this.ctrlRadius)||o.type===a.Circle&&this.isPointInCircle(t,o.coor,o.radius*this.scale)||o.type===a.Rect&&this.isPointInRect(t,o.coor)||o.type===a.Polygon&&this.isPointInPolygon(t,o.coor)||o.type===a.Line&&this.isPointInLine(t,o.coor)||o.type===a.Grid&&this.isPointInRect(t,o.coor))){if(this.focusMode&&!o.active)continue;i=s,e=o;break}}return[i,e]},o.prototype.isInBackground=function(t){var e=this.mergeEvent(t),i=e.mouseX,s=e.mouseY;return i>=this.originX&&s>=this.originY&&i<=this.originX+this.IMAGE_ORIGIN_WIDTH*this.scale&&s<=this.originY+this.IMAGE_ORIGIN_HEIGHT*this.scale},o.prototype.isPointInRect=function(t,e){var i=this,a=s(t,2),o=a[0],n=a[1],r=s(e.map(function(t){return t.map(function(t){return t*i.scale})}),2),h=s(r[0],2),c=h[0],l=h[1],d=s(r[1],2),u=d[0],v=d[1];return c+this.originX<=o&&o<=u+this.originX&&l+this.originY<=n&&n<=v+this.originY},o.prototype.isPointInPolygon=function(t,e){var i=this;if(!this.offScreenCtx)return!1;this.offScreenCtx.save(),this.offScreenCtx.clearRect(0,0,this.WIDTH,this.HEIGHT),this.offScreenCtx.translate(this.originX,this.originY),this.offScreenCtx.beginPath(),e.forEach(function(t,e){var a,o,n=s(t.map(function(t){return Math.round(t*i.scale)}),2),r=n[0],h=n[1];0===e?null===(a=i.offScreenCtx)||void 0===a||a.moveTo(r,h):null===(o=i.offScreenCtx)||void 0===o||o.lineTo(r,h)}),this.offScreenCtx.closePath(),this.offScreenCtx.fill();var a=this.offScreenCtx.getImageData(0,0,this.WIDTH,this.HEIGHT),o=(t[1]-1)*this.WIDTH*4+4*t[0];return this.offScreenCtx.restore(),0!==a.data[o+3]},o.prototype.isPointInCircle=function(t,e,i){var a=this,o=s(t,2),n=o[0],r=o[1],h=s(e.map(function(t){return t*a.scale}),2),c=h[0],l=h[1];return Math.sqrt(Math.pow(c+this.originX-n,2)+Math.pow(l+this.originY-r,2))<=i},o.prototype.isPointInLine=function(t,e){var i=this;if(!this.offScreenCtx)return!1;this.offScreenCtx.save(),this.offScreenCtx.clearRect(0,0,this.WIDTH,this.HEIGHT),this.offScreenCtx.translate(this.originX,this.originY),this.offScreenCtx.lineWidth=this.lineWidth>5?this.lineWidth:5,this.offScreenCtx.beginPath(),e.forEach(function(t,e){var a,o,n=s(t.map(function(t){return Math.round(t*i.scale)}),2),r=n[0],h=n[1];0===e?null===(a=i.offScreenCtx)||void 0===a||a.moveTo(r,h):null===(o=i.offScreenCtx)||void 0===o||o.lineTo(r,h)}),this.offScreenCtx.stroke();var a=this.offScreenCtx.getImageData(0,0,this.WIDTH,this.HEIGHT),o=(t[1]-1)*this.WIDTH*4+4*t[0];return this.offScreenCtx.restore(),0!==a.data[o+3]},o.prototype.drawRect=function(t,e){var i=this;if(this.ctx&&2===t.coor.length){var a=t.strokeStyle,o=void 0===a?"":a,n=t.fillStyle,r=void 0===n?"":n,h=t.active,c=t.creating,l=t.coor,d=t.lineWidth,u=t.rotation,v=s(l.map(function(t){return t.map(function(t){return Math.round(t*i.scale)})}),2),f=s(v[0],2),p=f[0],y=f[1],g=s(v[1],2),S=g[0],I=g[1],m=(p+S)/2,b=(y+I)/2,x=S-p,M=I-y;this.ctx.save(),this.ctx.lineWidth=d||this.lineWidth,(null==e?void 0:e.isSelected)?this.ctx.fillStyle=(null==e?void 0:e.selectedFillStyle)||r:this.ctx.fillStyle=h||c?this.activeFillStyle:r,this.ctx.strokeStyle=h||c?this.activeStrokeStyle:o,this.ctx.translate(m,b),this.ctx.rotate(u),this.ctx.translate(-m,-b),c||this.ctx.fillRect(p,y,x,M),this.ctx.strokeRect(p,y,x,M),this.ctx.restore(),this.drawLabel(l[0],t)}},o.prototype.drawPolygon=function(t){var e=this;if(this.ctx){var i=t.strokeStyle,a=void 0===i?"":i,o=t.fillStyle,n=void 0===o?"":o,r=t.active,h=t.creating,c=t.coor,l=t.lineWidth;this.ctx.save(),this.ctx.lineJoin="round",this.ctx.lineWidth=l||this.lineWidth,this.ctx.fillStyle=r||h?this.activeFillStyle:n,this.ctx.strokeStyle=r||h?this.activeStrokeStyle:a,this.ctx.beginPath(),c.forEach(function(t,i){var a,o,n=s(t.map(function(t){return Math.round(t*e.scale)}),2),r=n[0],h=n[1];0===i?null===(a=e.ctx)||void 0===a||a.moveTo(r,h):null===(o=e.ctx)||void 0===o||o.lineTo(r,h)});var d=h&&c.length>=this.MAX_POLYGON_POINTS;if(h&&!d){var u=s(this.mouse||[],2),v=u[0],f=u[1];this.ctx.lineTo(v-this.originX,f-this.originY)}else(c.length>2||d)&&this.ctx.closePath();this.ctx.fill(),this.ctx.stroke(),this.ctx.restore(),this.drawLabel(c[0],t)}},o.prototype.drawDot=function(t){var e=this;if(this.ctx){var i=t.strokeStyle,a=void 0===i?"":i,o=t.creating,n=t.fillStyle,r=void 0===n?"":n,h=t.active,c=t.coor,l=t.lineWidth,d=s(c.map(function(t){return t*e.scale}),2),u=d[0],v=d[1];this.ctx.save(),this.ctx.lineWidth=l||this.lineWidth,this.ctx.fillStyle=h||o?this.activeFillStyle:r,this.ctx.strokeStyle=h?this.activeStrokeStyle:a,this.ctx.beginPath(),this.ctx.arc(u,v,this.ctrlRadius,0,2*Math.PI,!0),this.ctx.fill(),this.ctx.arc(u,v,this.ctrlRadius,0,2*Math.PI,!0),this.ctx.stroke(),this.ctx.restore(),this.drawLabel(c,t)}},o.prototype.drawCirle=function(t){var e=this;if(this.ctx){var i=t.strokeStyle,a=void 0===i?"":i,o=t.fillStyle,n=void 0===o?"":o,r=t.active,h=t.coor,c=t.creating,l=t.radius,d=t.ctrlsData,u=t.lineWidth,v=s(h.map(function(t){return t*e.scale}),2),f=v[0],p=v[1];this.ctx.save(),this.ctx.lineWidth=u||this.lineWidth,this.ctx.fillStyle=r||c?this.activeFillStyle:n,this.ctx.strokeStyle=r||c?this.activeStrokeStyle:a,this.ctx.beginPath(),this.ctx.arc(f,p,l*this.scale,0,2*Math.PI,!0),this.ctx.fill(),this.ctx.arc(f,p,l*this.scale,0,2*Math.PI,!0),this.ctx.stroke(),this.ctx.restore(),this.drawLabel(d[0],t)}},o.prototype.drawEllipse=function(t){var e=this;if(this.ctx){var i=t.strokeStyle,a=void 0===i?"":i,o=t.fillStyle,n=void 0===o?"":o,r=t.active,h=t.coor,c=t.creating,l=t.radiusX,d=t.radiusY,u=t.rotation,v=t.lineWidth,f=s(h.map(function(t){return t*e.scale}),2),p=f[0],y=f[1],g=l*this.scale,S=d*this.scale;this.ctx.save(),this.ctx.lineWidth=v||this.lineWidth,this.ctx.fillStyle=r||c?this.activeFillStyle:n,this.ctx.strokeStyle=r||c?this.activeStrokeStyle:a,this.ctx.beginPath(),this.ctx.ellipse(p,y,g,S,u,0,2*Math.PI,!0),this.ctx.fill(),this.ctx.ellipse(p,y,g,S,u,0,2*Math.PI,!0),this.ctx.stroke(),this.ctx.restore(),this.drawLabel(t.ctrlsData[0],t)}},o.prototype.drawLine=function(t){var e=this;if(this.ctx){var i=t.strokeStyle,a=void 0===i?"":i,o=t.active,n=t.creating,r=t.coor,h=t.lineWidth;this.ctx.save(),this.ctx.lineJoin="round",this.ctx.lineWidth=h||this.lineWidth,this.ctx.strokeStyle=o||n?this.activeStrokeStyle:a,this.ctx.beginPath(),r.forEach(function(t,i){var a,o,n=s(t.map(function(t){return Math.round(t*e.scale)}),2),r=n[0],h=n[1];0===i?null===(a=e.ctx)||void 0===a||a.moveTo(r,h):null===(o=e.ctx)||void 0===o||o.lineTo(r,h)});var c=n&&r.length>=2;if(n&&!c){var l=s(this.mouse||[],2),d=l[0],u=l[1];this.ctx.lineTo(d-this.originX,u-this.originY)}else r.length;this.ctx.stroke(),this.ctx.restore(),this.drawLabel(r[0],t)}},o.prototype.drawGrid=function(t){var e=this;if(this.ctx&&2===t.coor.length){var i=t.strokeStyle,a=void 0===i?"":i,o=t.fillStyle,n=void 0===o?"":o,r=t.active,h=t.creating,c=t.coor,l=t.lineWidth,d=s(c.map(function(t){return t.map(function(t){return Math.round(t*e.scale)})}),2),u=s(d[0],2),v=u[0],f=u[1],p=s(d[1],2),y=p[0],g=p[1];this.ctx.save(),this.ctx.lineWidth=l||this.lineWidth,this.ctx.fillStyle=r||h?this.activeFillStyle:n,this.ctx.strokeStyle=r||h?this.activeStrokeStyle:a,t.gridRects.forEach(function(i,s){var a;e.drawRect(i,{selectedFillStyle:t.selectedFillStyle||e.gridSelectedFillStyle,isSelected:null===(a=t.selected)||void 0===a?void 0:a.includes(s)})});var S=y-v,I=g-f;h||this.ctx.fillRect(v,f,S,I),this.ctx.strokeRect(v,f,S,I),this.ctx.restore(),this.drawLabel(c[0],t)}},o.prototype.drawBrushPath=function(t){var e=this;if(this.ctx){var i=t.coor,a=t.brushSize,o=void 0===a?1:a,n=t.brushStokeStyle,r=void 0===n?"":n;this.ctx.save(),this.ctx.globalCompositeOperation="source-over",this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.lineWidth=Math.round(o*this.scale),this.ctx.strokeStyle=r,this.ctx.beginPath(),i.forEach(function(t,i){var a,o,n=s(t.map(function(t){return Math.round(t*e.scale)}),2),r=n[0],h=n[1];0===i?null===(a=e.ctx)||void 0===a||a.moveTo(r,h):null===(o=e.ctx)||void 0===o||o.lineTo(r,h)}),this.ctx.stroke(),this.ctx.restore()}},o.prototype.drawEraserPath=function(t){var e=this;if(this.ctx){var i=t.coor,a=t.eraserSize,o=void 0===a?1:a;this.ctx.save(),this.ctx.globalCompositeOperation="destination-out",this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.lineWidth=Math.round(o*this.scale),this.ctx.beginPath(),i.forEach(function(t,i){var a,o,n=s(t.map(function(t){return Math.round(t*e.scale)}),2),r=n[0],h=n[1];0===i?null===(a=e.ctx)||void 0===a||a.moveTo(r,h):null===(o=e.ctx)||void 0===o||o.lineTo(r,h)}),this.ctx.stroke(),this.ctx.restore()}},o.prototype.clearBrush=function(){var t=this.dataset.filter(function(t){return![a.Brush,a.Eraser].includes(t.type)});this.setData(t)},o.prototype.drawCtrl=function(t,e){var i=this;if(this.ctx){var a=s(t.map(function(t){return t*i.scale}),2),o=a[0],n=a[1];this.ctx.save(),this.ctx.beginPath(),this.ctx.fillStyle=e||this.ctrlFillStyle,this.ctx.strokeStyle=this.ctrlStrokeStyle,this.ctx.arc(o,n,this.ctrlRadius,0,2*Math.PI,!0),this.ctx.fill(),this.ctx.arc(o,n,this.ctrlRadius,0,2*Math.PI,!0),this.ctx.stroke(),this.ctx.restore()}},o.prototype.drawCtrlList=function(t){var e=this;t.ctrlsData.forEach(function(i,s){t.type===a.Circle?1===s&&e.drawCtrl(i):t.type===a.Ellipse?e.drawCtrl(i):e.drawCtrl(i,t.type===a.Rect&&8===s?"yellow":void 0)})},o.prototype.drawLabel=function(t,e){var i=this,o=e.label,n=void 0===o?"":o,r=e.labelFillStyle,h=void 0===r?"":r,c=e.labelFont,l=void 0===c?"":c,d=e.textFillStyle,u=void 0===d?"":d,v=e.hideLabel,f=e.labelUp,p=e.lineWidth,y="boolean"==typeof v?v:this.hideLabel,g="boolean"==typeof f?f:this.labelUp,S=p||this.lineWidth;if(this.ctx&&n.length&&!y){this.ctx.font=l||this.labelFont;var I=n.length<this.labelMaxLen+1?n:"".concat(n.slice(0,this.labelMaxLen),"..."),m=this.ctx.measureText(I),b=parseInt(this.ctx.font)-4,x=m.width+8,M=b+8,E=s(t.map(function(t){return t*i.scale}),2),H=E[0],T=E[1];if(e.type===a.Rect&&0!==e.rotation){var w=e,G=s(w.coor,2),k=s(G[0],2),C=k[0],_=k[1],D=s(G[1],2),P=D[0],W=D[1],R=(C+P)/2*this.scale,O=(_+W)/2*this.scale,L=H-R,A=T-O;H=L*Math.cos(w.rotation)-A*Math.sin(w.rotation)+R,T=L*Math.sin(w.rotation)+A*Math.cos(w.rotation)+O}var N=this.IMAGE_ORIGIN_WIDTH-t[0]<x/this.scale,X=this.IMAGE_ORIGIN_HEIGHT-t[1]<M/this.scale,Y=t[1]>M/this.scale,F=g?Y:X;this.ctx.save(),this.ctx.fillStyle=h||this.labelFillStyle,this.ctx.fillRect(N?H-m.width-4-S/2:H+S/2,F?T-M-S/2:T+S/2,x,M),this.ctx.fillStyle=u||this.textFillStyle,this.ctx.fillText(I,N?H-m.width:H+4+S/2,F?T-M+b+4:T+b+4+S/2,180),this.ctx.restore()}},o.prototype.update=function(){var t=this;window.cancelAnimationFrame(this.timer),this.timer=window.requestAnimationFrame(function(){var e,i,s;if(t.ctx){t.ctx.save(),t.ctx.clearRect(0,0,t.WIDTH,t.HEIGHT),t.ctx.translate(t.originX,t.originY);for(var o=t.focusMode?t.activeShape.type?[t.activeShape]:[]:t.dataset,n=o.filter(function(t){return t.type===a.Brush||t.type===a.Eraser}),r=0;r<n.length;r++){if(!(c=n[r]).hide)switch(c.type){case a.Brush:c.brushSize=null!==(e=c.brushSize)&&void 0!==e?e:t.brushSize,c.brushStokeStyle=null!==(i=c.brushStokeStyle)&&void 0!==i?i:t.brushStokeStyle,t.drawBrushPath(c);break;case a.Eraser:c.eraserSize=null!==(s=c.eraserSize)&&void 0!==s?s:t.eraserSize,t.drawEraserPath(c)}}var h=o.filter(function(t){return t.type!==a.Brush&&t.type!==a.Eraser});for(r=0;r<h.length;r++){var c;if(!(c=h[r]).hide)switch(c.type){case a.Rect:t.drawRect(c);break;case a.Polygon:t.drawPolygon(c);break;case a.Dot:t.drawDot(c);break;case a.Line:t.drawLine(c);break;case a.Circle:t.drawCirle(c);break;case a.Ellipse:t.drawEllipse(c);break;case a.Grid:t.drawGrid(c)}}!t.isCtrlKey&&t.showCross&&(t.drawLine(t.crossX),t.drawLine(t.crossY)),[a.Rect,a.Polygon,a.Line,a.Circle,a.Grid,a.Ellipse].includes(t.activeShape.type)&&!t.activeShape.hide&&t.drawCtrlList(t.activeShape),t.ctx.globalCompositeOperation="destination-over",t.IMAGE_WIDTH&&t.IMAGE_HEIGHT&&t.ctx.drawImage(t.image,0,0,t.IMAGE_WIDTH,t.IMAGE_HEIGHT),t.ctx.globalCompositeOperation="source-over",t.ctx.restore(),t.emit("updated",t.dataset)}})},o.prototype.deleteByIndex=function(t){var e=this.dataset.findIndex(function(e){return e.index===t});e>-1&&(this.emit("delete",this.dataset[e]),this.dataset.splice(e,1),this.dataset.forEach(function(t,e){t.index=e}),this.update())},o.prototype.deleteByUuid=function(t){var e=this.dataset.find(function(e){return e.uuid===t});e&&(this.emit("delete",e),this.dataset=this.dataset.filter(function(e){return e.uuid!==t}),this.update())},o.prototype.calcStep=function(t){void 0===t&&(t=""),this.IMAGE_WIDTH<this.WIDTH&&this.IMAGE_HEIGHT<this.HEIGHT&&(""!==t&&"b"!==t||(this.setScale(!0,!1,!0),this.calcStep("b"))),(this.IMAGE_WIDTH>this.WIDTH||this.IMAGE_HEIGHT>this.HEIGHT)&&(""!==t&&"s"!==t||(this.setScale(!1,!1,!0),this.calcStep("s")))},o.prototype.setScale=function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=!1),!this.lock&&!(!t&&this.imageMin<20||t&&this.IMAGE_WIDTH>100*this.imageOriginMax)){t?this.scaleStep++:this.scaleStep--;var a=0,o=0,n=s(this.mouse||[],2),r=n[0],h=n[1];e&&(a=(r-this.originX)/this.scale,o=(h-this.originY)/this.scale);var c=Math.abs(this.scaleStep),l=this.IMAGE_WIDTH;if(this.IMAGE_WIDTH=Math.round(this.IMAGE_ORIGIN_WIDTH*Math.pow(this.scaleStep>=0?1.05:.95,c)),this.IMAGE_HEIGHT=Math.round(this.IMAGE_ORIGIN_HEIGHT*Math.pow(this.scaleStep>=0?1.05:.95,c)),e)this.originX=r-a*this.scale,this.originY=h-o*this.scale;else{var d=this.IMAGE_WIDTH/l;this.originX=this.WIDTH/2-(this.WIDTH/2-this.originX)*d,this.originY=this.HEIGHT/2-(this.HEIGHT/2-this.originY)*d}i||this.update()}},o.prototype.fitZoom=function(){this.calcStep(),this.IMAGE_HEIGHT/this.IMAGE_WIDTH>=this.HEIGHT/this.WIDTH?(this.IMAGE_WIDTH=this.IMAGE_ORIGIN_WIDTH/(this.IMAGE_ORIGIN_HEIGHT/this.HEIGHT),this.IMAGE_HEIGHT=this.HEIGHT):(this.IMAGE_WIDTH=this.WIDTH,this.IMAGE_HEIGHT=this.IMAGE_ORIGIN_HEIGHT/(this.IMAGE_ORIGIN_WIDTH/this.WIDTH)),this.originX=(this.WIDTH-this.IMAGE_WIDTH)/2,this.originY=(this.HEIGHT-this.IMAGE_HEIGHT)/2,this.update()},o.prototype.setFocusMode=function(t){this.focusMode=t,this.update()},o.prototype.destroy=function(){this.canvas&&(this.image.removeEventListener("load",this.handleLoad),this.canvas.removeEventListener("contextmenu",this.handleContextmenu),this.canvas.removeEventListener("mousewheel",this.handleMousewheel),this.canvas.removeEventListener("wheel",this.handleMousewheel),this.canvas.removeEventListener("mousedown",this.handleMouseDown),this.canvas.removeEventListener("touchend",this.handleMouseDown),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("touchmove",this.handleMouseMove),this.canvas.removeEventListener("mouseup",this.handleMouseUp),this.canvas.removeEventListener("touchend",this.handleMouseUp),this.canvas.removeEventListener("dblclick",this.handleDblclick),document.body.removeEventListener("keydown",this.handleKeydown,!0),document.body.removeEventListener("keyup",this.handleKeyup,!0),this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="",this.canvas.style.height="",this.canvas.style.userSelect="")},o.prototype.resize=function(){this.canvas&&(this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this.canvas.style.width="",this.canvas.style.height="",this.initSetting(),this.update())},o}(c)});
|
|
8
|
+
//# sourceMappingURL=canvas-select.min.js.map
|