账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    canvas 绘制路径重叠的问题
    64
    0
    在填充绘制路径时,getContext.fill()方法有两个参数,当为'evenodd'时,重叠的部分去掉,为啥在我这里不行,请问如何修改呢?<canvas id=c></canvas><script> var w = c.width = window.innerWidth, h = c.height = window.innerHeight, ctx = c.getContext('2d'), offset = 0; points = []; function smoothLine(points) { ctx.fillStyle="red"; ctx.fill('evenodd'); // 主要是这里; ctx.lineWidth = 3; ctx.strokeStyle = '#eee'; ctx.lineTo(points[points.length - 1].x, points[points.length - 1].y); ctx.setLineDash([5, 4, 3]); march(); ctx.lineDashOffset = offset; ctx.stroke(); } function march() { offset++; if (offset > 15) { offset = 0; } setTimeout(march, 20); } c.onmousedown = function (e) { points.push({x: e.clientX, y: e.clientY}); ctx.fill('evenodd'); c.onmousemove = function (e) { points.push({x: e.clientX, y: e.clientY}); smoothLine(points); }; c.onmouseup = function () { ctx.closePath() c.onmousemove = null; c.onmouseup = null; }; };</script>
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部