我正在尝试获得圆形笔尖,但下面的代码会创建一个带有线条形状的笔尖。
context.lineWidth = 1;
context.lineCap = "round";
如何获得圆形笔尖?
答案 0 :(得分:2)
您只需绘制画布的路径并将lineCap
设置为round
。
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
context.beginPath();
context.moveTo(10, 10);
context.lineTo(canvas.width/2, canvas.height / 2);
context.lineWidth = 10;
context.strokeStyle = "red";
context.lineCap = "round";
context.stroke();