We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Gray color Bug
Page Index Toggle Pages: 1
Gray color Bug (Read 474 times)
Gray color Bug
Apr 20th, 2008, 7:48pm
 
(NOT A BUG)>> I had a strange problem.

My program had 3 options to fill a rectangle:
1- fill gray:
 fill(128)
2- vertical stripes:
 fill(255) + vertical stroke(0) lines at even columns
3- horizontal stripes:
 fill(255) + horizontal stroke(0) lines at even rows

Running the program, options_1 and options_2 gave the same apparent color, but option_3 was very much brighter.
So it seems line() paints horizontal lines incorrectly.

So I put those options in a very small bugdemo program to show you the bug. But running bugdemo did not show the bug: the 3 options had same brightgness.

I checked my program again, finding no other error, but still producing option_3 with the wrong brightness.
I thought some weird graphic setup error must be happening in Processing producing the bug in my program, but not in the simpler bugdemo.

To better understand at the pixel level, I prinstscreen the output for both vertical and horizontal options and checked them in Paint under magnification. One had perfect alternate black and white vertical lines, the other had perfect alternate black and white horizontal lines. That was perfect, but unexpected. And my program still showed a very great difference in brightness, while my smaller bugdemo program did not show it.
Then I realized: it's the monitors!!
I'm using 2 monitors, my LCD in front, my CRT on the right.
My LCD (running my bugdemo) shows correct gray brightness, not my CRT (running my program). Its obvious if I move my window on both monitors.
I don't know the exact reason, but it's probably that the width and height of a pixel are different on my CRT.
So it's a bug, but not a software bug, not a Processing bug.
Now I need a coffee...

Try it on your monitor: Code:
int count=0;

void setup() {
size(600,600);
background(153);
}//setup()

void draw() {
showStripes();
}//draw()

void showStripes() {
if (count%2==0)
bw_Vertical();
else bw_Horizontal();
delay(1000);
println(count);
if (count++==10) exit();
}//showStripes()

void bw_Vertical(){
fill(255,255);
rect(0,0,width,height);
strokeWeight(1);
stroke(0,255);
for (int x=1; x<width; x+=2) {
line(x, 0, x, height-1);
}
}//bw_Vertical()

void bw_Horizontal(){
fill(255,255);
rect(0,0,width,height);
strokeWeight(1);
stroke(0,255);
for (int y=1; y<height; y+=2) {
line(0, y, width-1, y);
}
}//bw_Horizontal()
Page Index Toggle Pages: 1