We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've got the following code:
void setup() {
size(400, 400);
colorMode(RGB,255,255,255,255);
background(color(51, 85, 204));
noStroke();
}
void draw() {
fill(color(255), 1);
rect(0,0,width/2, height);
fill(color(255), 100);
rect((width/2) - 10, (height/2) - 10, 20, 20);
}
My expectation is that the alpha value on the left rect would result in a transparent rectangle that gradually fades to white, but it seems to stop at an off-white. Increasing the alpha gets it closer to white, but any low value (below 35 or so) seems to result in an imperfect fading effect.
Is this just a result of the color values being integers rather than floats, or is there something else going on? And is there any way to fix this, other than just increasing the alpha?
Answers
This was answered here: http://stackoverflow.com/questions/22317685/why-does-the-processing-fill-with-alpha-never-completely-fill
Basically, eventually the difference between the source and the destination colors become close enough that the fade difference is less than 1. When this happens, the fading stops.
The solution is to create your own fade instead of relying on an alpha blend.