UNPKG

@tomiaa/canvas-graffiti

Version:
23 lines (22 loc) 621 B
const e = { pointerdown({ offsetX: i, offsetY: s }) { this.ctx.beginPath(), this.points.push({ x: i, y: s }); }, pointermove({ offsetX: i, offsetY: s }) { if (this.points.push({ x: i, y: s }), this.points.length < 3) return; const t = this.points.slice(-2), n = t[0], o = { x: (t[0].x + t[1].x) / 2, y: (t[0].y + t[1].y) / 2 }; this.ctx.beginPath(), this.ctx.moveTo(this.beginPoint.x, this.beginPoint.y), this.ctx.quadraticCurveTo( n.x, n.y, o.x, o.y ), this.ctx.stroke(), this.ctx.closePath(), this.beginPoint = o; } }; export { e as Marker };