这个小代码在间隔清除旧帆布数据:帆布填充样式与透明间隔/不透明度
// 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