(I’m using GWT, which wraps javasciprt / html, so think it applies here as well).
I’d like to use a color with varying opacity on a canvas element. It looks like I have to keep creating a CssColor over and over again as there is no setOpacity() method that I can see:
// fade in
for (int i = 0; i < 255; i++) {
CssColor clr = CssColor.make("rgba(" + 255 + ", " + 0 + "," + 0 + ", " + i + ")");
canvas.setFillStyle(clr);
canvas.fillRect(...);
}
Is there any way to just modify the alpha value on a constructed color, rather than creating all these new objects?
Thanks
You can use setGlobalAlpha(double alpha)