這個小代碼在間隔清除舊帆布數據:帆布填充樣式與透明間隔/不透明度
// start interval
ctx.save();
ctx.fillStyle = "rgba(0, 0, 0, 0.2)";
ctx.fillRect(0, 0, ctx.width, ctx.height);
ctx.restore();
//some draw code for new graph
...
//end interval
我的工作區成爲黑色,因爲我設置黑色作爲填充顏色(RGBA(0,0,0, .2)),但我需要一個透明背景,而不是黑色。
我試過使用globalAlpha和imagePutData,但我失敗了。
我該怎麼做?
你試過'clearRect'? – c69
如果我明確的矩形,它清除所有舊數據,但我需要保存舊數據,併爲它設置不透明度(我爲什麼使用RGBA顏色模型,),直到間隔使其完全透明 – user951114
也許設定'ctx.globalCompositeOperation =「目的地'出',然後畫? – c69