UNPKG

@jianghh/canvas-graffiti

Version:

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

2 lines (1 loc) 606 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i={buffer:!0,pointerdown({offsetX:t,offsetY:e}){this.bufferCtx.moveTo(t,e)},pointermove({offsetX:t,offsetY:e}){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,e),this.endPoint={x:t,y:e},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())}};exports.Line=i;