2
我在畫布上畫了一個圓圈,其中一個頂部,問題是您可以通過前面一個(紅色輪廓)看到背部。有沒有辦法改善這一點?CSS畫布圓平滑度
我能想到的唯一的事情是增加頂部的大小(lineWidth by pixel或2)以完全覆蓋後面的一個。
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var canvas2 = document.getElementById('myCanvas2');
var context2 = canvas2.getContext('2d');
var centerX = canvas.width/2;
var centerY = canvas.height/2;
var radius = 70;
for (var i = 0; i < 1; i++) {
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.lineWidth = 25;
context.strokeStyle = '#ff0000';
context.stroke();
}
for (var i = 0; i < 1; i++) {
context2.beginPath();
context2.arc(centerX, centerY, radius, 0, 2.5, false);
context2.lineWidth = 25;
context2.strokeStyle = '#fff';
context2.stroke();
}
#myCanvas,
#myCanvas2{
position:absolute;
}
<canvas id="myCanvas" width="578" height="200"></canvas>
<canvas id="myCanvas2" width="578" height="200"></canvas>
https://jsfiddle.net/0zs2gqxk/3/
@Toniq讓我知道你對此的想法,謝謝! – kukkuz
我不明白如何開始角度改變這種行爲? – Toniq
@Toniq我們不會畫紅色的白色圓弧,而是完成圓圈...... – kukkuz