gpt4 book ai didi

javascript - Canvas - 多重合成操作

转载 作者:行者123 更新时间:2023-11-30 16:52:36 26 4
gpt4 key购买 nike

是否可以在绘制不同“事物”时使用多重合成?

例如,我想对特定类型的 fillRect 使用打火机,但对于其余部分,我想保持一切照常。

最佳答案

当然,合成模式可以在每次绘制之前即时更改,因此您可以将某些绘制操作更改为“打火机”,对其他操作更改为“源代码”。

请注意,某些合成模式可能会清除已绘制的内容,因此请明智地选择。

ctx.globalCompositeOperation = "lighter";      // lighter mode (blend mode)
ctx.fillRect(x, y, w, h);

ctx.globalCompositeOperation = "source-over"; // normal mode (comp mode)
ctx.fillRect(x, y, w, h);

关于javascript - Canvas - 多重合成操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30282908/

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