UNPKG

jianghh-canvas

Version:

canvas画板,支持笔写、手写、鼠标流畅绘图,自动保存,撤销重做

16 lines (15 loc) 641 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.arc(this.beginPoint.x, this.beginPoint.y, Math.abs(t - this.beginPoint.x), 0, 2 * Math.PI), this.endPoint = { x: t, y: i }, this.bufferCtx.stroke(); }, pointerup() { this.endPoint && (this.ctx.beginPath(), this.ctx.arc(this.beginPoint.x, this.beginPoint.y, Math.abs(this.endPoint.x - this.beginPoint.x), 0, 2 * Math.PI), this.ctx.stroke()); } }; export { e as Arc };