Hi,
I am including a simpler example that demonstrates
the difficulty I am trying to eliminate.
In the code below, the grey-level "g" varies smoothly from 0 to 255
as the vertical lines are drawn from left to right.
The alpha blending value "a" is 12 (out of 255).
The program repeatedly draws the vertical lines with
the continuous ramp of grey-levels, ... but the image
that accumulates over time has a very small number
of discrete grey levels.
Basically, if the alpha-blending was being done using floating point,
the continuous ramp of grey would slowly emerge, but I think the
staircase is a consequence of pixels being rounded to the nearest integer
on each iteration.
This problem is a simplified version of what I am really trying
to do in a larger sketch. I want to draw many layers of colour
with very small alpha blending values to create transluscent layers
... without these annoying discrete steps.
-- djones
Quote:
// demo_alpha_bug_2
float x = 0;
void setup() {
size(512,256);
background(0);
frameRate(240);
strokeWeight(1);
}
void draw() {
float g, a;
a = 12;
g = 256.0*x/width;
stroke(g, a);
line(x,0, x,height);
if (++x > width) {
x = 0;
}
}