gpt4 book ai didi

javascript - Canvas fillStyle 间隔透明/不透明

转载 作者:可可西里 更新时间:2023-11-01 02:05:59 25 4
gpt4 key购买 nike

这段小代码间隔清除旧 Canvas 数据:

// 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)),但我需要透明背景,而不是黑色。

我尝试使用 globalAlphaimagePutData 但我失败了。

我该怎么做?

最佳答案

我认为这会解决您的问题

ctx.fillStyle = "rgba(255, 255, 255, 0.5)";

关于javascript - Canvas fillStyle 间隔透明/不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7460927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com