我正在試驗Canvas,在網格中放置不同顏色的標記,並嘗試刪除它們。爲什麼Canvas會留下幽靈般的戒指?
我目前正試圖通過在令牌繪製精確的相同尺寸的圓形白色刪除令牌。這會留下原始圓圈的「鬼環」(單像素輪廓),隨着白圈的連續應用而消失。
在2圓,-1最初繪製,而不是在所有上述磨削。 3中的圓圈-1已被重疊一次,4中的圓圈-1已被重疊兩次,以此類推至7,-1。
在Chrome和Firefox 3.6中均會出現此行爲
我的代碼如下所示。
function placeToken(e) {
var click = getClick(e);
var gridCord = getGridCord(click);
var canvas = e.currentTarget;
var ctx = canvas.getContext(CONTEXT_NAME);
ctx.fillStyle = color;
ctx.strokeStyle = color; //tried with and without this line, no effect
x = (gridCord.x * spacing) + (spacing/2);
y = (gridCord.y * spacing) + (spacing/2);
ctx.beginPath();
ctx.arc(x, y, (spacing - tokenEdge)/2, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.stroke(); //tried with and without this line. Same result
};
爲什麼畫布離開這個幽靈般的戒指,我該如何擺脫它?
它是由Flash開發人員非常衆所周知,帆布鬧鬼 – Jason 2010-12-15 23:44:24
總之,抗鋸齒。該圓的邊緣上的像素被繪製的不透明度小於100%。這不是畫布所特有的。你只需要畫它。 – 2010-12-15 23:44:29