jianghh-canvas
Version:
canvas画板,支持笔写、手写、鼠标流畅绘图,自动保存,撤销重做
2 lines (1 loc) • 540 B
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={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),n=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(n.x,n.y,s.x,s.y),this.ctx.stroke(),this.ctx.closePath(),this.beginPoint=s}};exports.Pen=e;