Created by: PianoMastR64
void setup() {
size(800, 800, P2D);
noLoop();
clear();
noStroke();
//stroke(255, 0, 0, 255/2);
//strokeWeight(50);
fill(255, 255/2);
square(0, 0, 400); // top left
printColor(get(200, 200)); // prints top left color info
}
void draw() {
square(400, 400, 400); // bottom right
printColor(get(200, 200)); // prints top left color info
printColor(get(600, 600)); // prints bottom right color info
}
void printColor(color c){
println("color: (" +
red(c) + ", " +
green(c) + ", " +
blue(c) + ", " +
alpha(c) + ")");
}
If you run this code, you'll see that even though the fill color is the same for both squares, the first one in setup() appears darker than it should. The other square in draw() is drawn correctly. This is only a problem when using the P2D renderer after calling clear(), which effectively calls background(0, 0).
If you modify only the renderer to the default size(800, 800);, then both squares are drawn correctly. If you modify only the clear() line into background(0), then both squares are also drawn correctly.
I commented out the stroke lines because they're a bit distracting, but they also convey some interesting information as they're also affected by this bug.
It's also interesting to note that get() in setup() insists that the top left square is (127, 127, 127, 127), but in draw() it says it's (63, 63, 63, 127) which is what Paint confirms it is in a screenshot (minus the alpha).
One more thing is that only translucent shapes are affected, and the lower the alpha, the more dramatic the effect.
Created by: PianoMastR64
If you run this code, you'll see that even though the fill color is the same for both squares, the first one in
setup()appears darker than it should. The other square indraw()is drawn correctly. This is only a problem when using theP2Drenderer after callingclear(), which effectively callsbackground(0, 0).If you modify only the renderer to the default
size(800, 800);, then both squares are drawn correctly. If you modify only theclear()line intobackground(0), then both squares are also drawn correctly.I commented out the stroke lines because they're a bit distracting, but they also convey some interesting information as they're also affected by this bug.
It's also interesting to note that
get()insetup()insists that the top left square is (127, 127, 127, 127), but indraw()it says it's (63, 63, 63, 127) which is what Paint confirms it is in a screenshot (minus the alpha).One more thing is that only translucent shapes are affected, and the lower the alpha, the more dramatic the effect.