UNPKG

@tomiaa/canvas-graffiti

Version:
26 lines (25 loc) 828 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.rect( this.beginPoint.x, this.beginPoint.y, t - this.beginPoint.x, i - this.beginPoint.y ), 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.rect( this.beginPoint.x, this.beginPoint.y, this.endPoint.x - this.beginPoint.x, this.endPoint.y - this.beginPoint.y ), this.ctx.stroke()); } }; export { e as Rect };