We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I see that with the alpha() function we can extract the alpha value of a color. But is there a way to set this value without using fill? I would like to set the alpha value to an unknown color.
If I understand your question correctly, you can do something like this:
//Red, no alpha
color c = color(255, 0, 0);
//Change the alpha (not the most elegant, perhaps...)
c = color(red(c), green(c), blue(c), 127);
There is also a way to do this by shifting bits, but I don't know how to do that off of the top of my head...
color c = pixels;
println(hex(c)); // pixel color
color a = c >>> 030;
println(hex(a, 2)); // extracted alpha octet
println(hex(a >>= 1, 2)); // half of alpha
println(hex(c &= 0xFFFFFF)); // clear alpha octet
println(hex(c |= a << 030)); // reinserts modified alpha