javascript - html5 Canvas 线宽空格

标签 javascript html canvas stroke

我使用 html5 canvas 来像油漆一样绘图,如果我用细画笔大小绘画,我的问题是很好很光滑,但如果我增加画笔大小,我会得到空格。

code: http://jsfiddle.net/L2g43q1g/

细画笔尺寸结果: enter image description here http://postimg.org/image/eyxenntth/

大画笔尺寸结果: enter image description here http://postimg.org/image/60agxczf9/

最佳答案

我认为你需要颠倒 context.closePath() 和 context.Stroke() 的顺序,并添加 context.lineJoin = "round"

更新了中风功能:

function stroke(mouseX, mouseY) {
    context.beginPath();
    context.lineJoin = "round";
    context.lineWidth = 10; //1 = thin line without spaces, 10 = big line with spaces..
    context.moveTo(prevMouseX, prevMouseY);
    context.lineTo(mouseX, mouseY);
    context.closePath();
    context.stroke();


    prevMouseX = mouseX;
    prevMouseY = mouseY;
}

关于javascript - html5 Canvas 线宽空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27841482/

相关文章:

javascript - 是什么让这个伪 GUID 生成器比 math.random() 更好?

html - 使用 CSS3 的文本阴影效果

html - 我可以创建一个延伸到页面底部的内容 div,具有可变高度标题,没有滚动条吗?

javascript - 停止$.each,加载图像然后继续循环

javascript - Canvas Sprite 表错误

javascript - 如何操作JSON数据?

javascript - TinyMCE:从 TinyMCE 到常规文本字段的实时复制文本

javascript - 错误 : Object #<Object> has no method 'toUpperCase'

javascript - 空消息未显示在 ng-repeat angularjs 的空表中

javascript - Onload() 处理程序在 IE 中没有响应