设为首页 加入收藏

TOP

canvas鼠标拖动绘制图形(三)
2017-10-16 18:19:17 】 浏览:5717
Tags:canvas 鼠标 绘制 图形
veTo(this.polygonVertex[0],this.polygonVertex[1]),this.ctx.lineTo(this.polygonVertex[2],this.polygonVertex[3]),this.ctx.lineTo(this.polygonVertex[4],this.polygonVertex[5]),this.ctx.lineTo(this.polygonVertex[6],this.polygonVertex[7]),this.ctx.lineTo(this.polygonVertex[8],this.polygonVertex[9]),this.ctx.lineTo(this.polygonVertex[10],this.polygonVertex[11]),this.ctx.closePath(),this.ctx.fill()},this.createRect=function(t,e,i,s,r,o,a,h){this.ctx.beginPath(),this.ctx.moveTo(t,e+r),this.ctx.lineTo(t,e+s-r),this.ctx.quadraticCurveTo(t,e+s,t+r,e+s),this.ctx.lineTo(t+i-r,e+s),this.ctx.quadraticCurveTo(t+i,e+s,t+i,e+s-r),this.ctx.lineTo(t+i,e+r),this.ctx.quadraticCurveTo(t+i,e,t+i-r,e),this.ctx.lineTo(t+r,e),this.ctx.quadraticCurveTo(t,e,t,e+r),this.ctx[a+"Style"]=o,this.ctx.lineWidth=h,this.ctx.closePath(),this.ctx[a]()},this.drawRect=function(t,e,i,s,r,o,a){this.createRect(t,e,i,s,r,o,"stroke",a)},this.drawEllipse=function(t,e,i,s,r,o){this.ctx.beginPath(),this.ctx.ellipse(t,e,i,s,0,0,2*Math.PI),this.ctx.lineWidth=r,this.ctx.fillStyle="rgba(0,0,0,0)",this.ctx.strokeStyle=o,this.ctx.fill(),this.ctx.stroke()},this.clear=function(){this.ctx.clearRect(0,0,this.w,this.h)},this.redrawAll=function(){var t=this;this.status.rectArr.length>0&&this.status.rectArr.forEach(function(e){t.drawRect(e.realX,e.realY,e.width,e.height,e.radius,e.color,e.lineWidth)}),this.status.circleArr.length>0&&this.status.circleArr.forEach(function(e){t.drawEllipse(e.x,e.y,e.a,e.b,e.lineWidth,e.color)}),this.status.lineArr.length>0&&this.status.lineArr.forEach(function(e,i){t.drawPoint(e.x,e.y,e.clickDrag,e.lineWidth,e.color)}),this.status.arrowArr.length>0&&this.status.arrowArr.forEach(function(e,i){e.beginPoint!={}&&(t.arrowCoord(e.beginPoint,e.stopPoint,e.range),t.sideCoord(),t.drawArrow(e.color))})}}console.log("\n %c Ypaint 1.0.1 %c \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;"),CONST={edgeLen:25,angle:15},window.Ypaint=function(e){var i=new t;return i.init(e),i}}();

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇图片首尾平滑轮播(JS原生方法—节.. 下一篇前端HTML以及HTML5(基本标签)

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目