Reputation: 6531
Is it possible to use multiple compositing for different "things" when they're being drawn?
For instance I want to use lighter for specific kinds of fillRect's, but for the rest i want to keep everything as usual.
Upvotes: 1
Views: 147
Reputation:
Sure, composition mode can be changed on the fly before each drawing so you can change to "lighter" for some draw operations, "source-over" for others.
Just be aware of that some comp modes may clear what is already drawn so choose wisely.
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);
Upvotes: 2