Bug 850 : Alpha fill too weak
Last modified: 2008-07-15 09:29




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
liminal
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2008-07-14 13:36
Repeatedly using an alpha fill to fade the drawing surface leaves a trace,
regardless of how many times done.

Tested with version 135 on Vista 32-bit.

Example program:

void setup() {
size(300, 300);
background(0);
fill(255);
rect(50, 50, 200, 200);
}

void draw() {
fill(0, 2);
rect(0, 0, width, height);
}
Additional Comment #1 From liminal 2008-07-15 09:18
Discussed this with a colleague and in the process improved the program to
plot out the change in colour as the alpha-rectangle is repeatedly painted
over. Correct behaviour would cause the green dot to make a smooth
transition down to the bottom of the viewer. Instead, the path is piecewise
linear, and even for alpha values as high as 127, never makes it to 0.

Here is an improved version of the code that prints and plots the current
value.

void setup() {
size(300, 300);
background(0);
fill(255);
rect(50, 50, 200, 200);
}

void draw() {
fill(0, 4);
noStroke();
rect(0, 0, width, height);

stroke(0, 255, 0);
strokeWeight(2);
point(frameCount % width, height - height * red(get(100, 100)) / 255.0);
println(red(get(100, 100)));
}
Additional Comment #2 From fry 2008-07-15 09:29
This is a mathematical fact of life... Alpha blending is multiplicative so
you'll never get all the way there.

(For what it's worth, we inherit this particular behavior from Java, so
you'd need to take it up with them if you want things to behave otherwise.)