Javascript 如何用画布去除饼图中的暗线?

Javascript 如何用画布去除饼图中的暗线?,javascript,canvas,html5-canvas,2d,Javascript,Canvas,Html5 Canvas,2d,我正在制作一个类似于饼图的颜色圈,它由列表[0..n]组成。问题是在每一片之间都有一些模糊的暗线。如图所示,绿色尤其明显 这是我的密码: const canvas=document.getElementById('canvas'); const context=canvas.getContext('2d'); const list=Array.from({length:100},(u,i)=>i+1);//生成列表 context.fillStyle='#000000'; context.f

我正在制作一个类似于饼图的颜色圈,它由列表[0..n]组成。问题是在每一片之间都有一些模糊的暗线。如图所示,绿色尤其明显

这是我的密码:

const canvas=document.getElementById('canvas');
const context=canvas.getContext('2d');
const list=Array.from({length:100},(u,i)=>i+1);//生成列表
context.fillStyle='#000000';
context.fillRect(0,0,canvas.width,canvas.height);
const center=[Math.floor(canvas.width/2)、Math.floor(canvas.height/2)];
常数半径=数学最小值(中心[0],中心[1]);
让prevAngle=0;
for(设i=0;i

看起来这是由于亚像素的不精确性造成的。你可以让线条稍微粗一点,让它不那么明显:

context.lineWidth = 1.5;
const canvas=document.getElementById('canvas');
const context=canvas.getContext('2d');
const list=Array.from({length:100},(u,i)=>i+1);//生成列表
context.fillStyle='#000';
context.lineWidth=1.5//