UNPKG

@tomiaa/canvas-graffiti

Version:
2 lines (1 loc) 543 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n={pointerdown({offsetX:i,offsetY:o}){this.ctx.beginPath(),this.points.push({x:i,y:o})},pointermove({offsetX:i,offsetY:o}){if(this.points.push({x:i,y:o}),this.points.length<3)return;const t=this.points.slice(-2),e=t[0],s={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(e.x,e.y,s.x,s.y),this.ctx.stroke(),this.ctx.closePath(),this.beginPoint=s}};exports.Marker=n;