UNPKG

@jianghh/canvas-graffiti

Version:

canvas涂鸦库,支持手写、笔写、鼠标,选中元素,并且移动、删除等功能。集成撤销重做操作。

16 lines (15 loc) 616 B
const e = { buffer: !0, pointerdown({ offsetX: t, offsetY: i }) { this.bufferCtx.moveTo(t, i); }, pointermove({ offsetX: t, offsetY: i }) { this.bufferCtx.clearRect(0, 0, this.el.width, this.el.height), this.bufferCtx.beginPath(), this.bufferCtx.moveTo(this.beginPoint.x, this.beginPoint.y), this.bufferCtx.lineTo(t, i), this.endPoint = { x: t, y: i }, this.bufferCtx.stroke(); }, pointerup() { this.endPoint && (this.ctx.beginPath(), this.ctx.moveTo(this.beginPoint.x, this.beginPoint.y), this.ctx.lineTo(this.endPoint.x, this.endPoint.y), this.ctx.stroke()); } }; export { e as Line };