试图在画布上删除弧的边框

bla*_*uma 6 javascript canvas html5-canvas

我使用HTML canvas arc方法绘制了一个圆圈,但我想删除圆的边框.我试着设置lineWidth = 0但它似乎不起作用.有没有办法在画布中删除圆圈的边框?

$(document).ready(function() {
    pie_chart = $('#pie_chart');
    var p = pie_chart[0].getContext('2d');

    var canvas_width = pie_chart.width();
    var canvas_height = pie_chart.height();

    p.beginPath();
    p.arc(canvas_width/2, canvas_height/2, 150, 0 , Math.PI * 2);
    p.lineWidth = 0;
    p.stroke();
    p.fillStyle = '#777';
    p.fill();
});
Run Code Online (Sandbox Code Playgroud)

小智 11

简单的答案是:只需stroke()拨打电话:

p.beginPath();
p.arc(canvas_width/2, canvas_height/2, 150, 0 , Math.PI * 2);
p.lineWidth = 0;
//p.stroke();
p.fillStyle = '#777';
p.fill();
Run Code Online (Sandbox Code Playgroud)