Let's say we have the following code:
void setup() {
background(0);
size(200, 200);
fill(255);
rect(75, 75, 50, 50);
}
void draw() {
fill(0, 2);
rect(0, 0, width, height);
}
Even after waiting 'forever,' the white 50x50 rectangle is still visible, albeit faded. Why doesn't the fill(0, 2)
eventually cover this up?
I suppose this question is twofold:
fill() Sets the color used to fill shapes. For example, if you run fill(204, 102, 0), all subsequent shapes will be filled with orange. This color is either specified in terms of the RGB or HSB color depending on the current colorMode() (the default color space is RGB, with each value in the range from 0 to 255).
What is Alpha Processing and what types are there? Alpha processing was the world's first technical formula for reproducing 16-bit data in 20-bit quality. The ALPHA processor interpolates the data recorded on the original CD so that the waveform is more natural.
By adding the stroke() and fill() functions before something is drawn, we can set the color of any given shape. There is also the function background(), which sets a background color for the window. Here's an example. Stroke or fill can be eliminated with the functions: noStroke() and noFill().
Here's a post explaining what's going on: http://processing.org/discourse/beta/num_1138703939.html
Basically, the problem is that Processing stores colors as ints, but takes float arguments. When combining colors, Processing rounds the floats to ints. In your case, your color is getting stuck at a value of 63, 63, 63 because at that point the blending is too slight to make a difference that is detectable after rounding.
The solution is to do the fading from the source, not by overlaying an alpha color over top.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With