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 › Stroke/fill on ellipse different in pixel[] array
Page Index Toggle Pages: 1
Stroke/fill on ellipse different in pixel[] array (Read 1020 times)
Stroke/fill on ellipse different in pixel[] array
Dec 27th, 2005, 3:17pm
 
On a program I'm writing in P3D I have a colour defined as:
color grass = color(141,168,96);
and when I add an ellipse to the stage using
 fill(grass);
 stroke(grass);
the value in the pixel array for the fill is "9283680" and for the stroke it is "-14606047"
anyone know why the values are slightly different?


just done a bit more testing

void setup(){
size(200,200,P3D);
background(0);
stroke(255,255,0);
fill(255,255,0);
ellipse(100,100,40,40);
loadPixels();
}

void draw(){

}

void keyPressed(){
 if(key == 'f'){
 println(pixels[mouseY*width+mouseX]);
 }
}


if you run this program and then press f while over the fill or the stroke of the circle then you get different readings. Anyone know why this is or how I can cause the fill pixels entry to be the same as the stroke one.
Re: Stroke/fill on ellipse different in pixel[] ar
Reply #1 - Dec 27th, 2005, 8:09pm
 
interesting.

Perhaps it might be an ambient light issue?

call: ambientFromCalc(); occurs in fillFromCalc method in P3D. No similar strokeFromCalc method.

adding call ambientLight(0,0,0); to your sketch doesn't seem to impact stroke col at all.

I'm guessing we're getting some additional calc for fill based on ambient that we're not getting for stroke?

sorry no more time to further investigate. Hope this helps (at all.)

ig
Re: Stroke/fill on ellipse different in pixel[] ar
Reply #2 - Dec 28th, 2005, 9:05pm
 
Cheers!
Makes sense, anyone know if I could prevent this happening to my fill pixels or if there is a way I can make processing read the two different values as the same kind.
Re: Stroke/fill on ellipse different in pixel[] ar
Reply #3 - Dec 29th, 2005, 3:58pm
 
for 3D work, lighting won't affect the stroke so that'll cause some weirdness, however since you're not using lights, that's likely not what's causing the difference.

i'm guessing it has to do with the accuracy of the renderer... P3D isn't made to be accurate, and uses all fixed point integers internally so there might be some quantization of colors and some error in the roundoff. the stroke will be affected by that a bit as well, but perhaps not in the same way.

you might check to see how different things actually are.. use the hex() function to print the values as hex digits (more readable) rather than ints, since the int doesn't really tell us much.
Re: Stroke/fill on ellipse different in pixel[] ar
Reply #4 - Jan 2nd, 2006, 8:07pm
 
cheers fry the hex is what I was looking for (no idea how I missed that), unfortunately using hex for each pixel I look at is too intensive so I took my approach the other way and instead of using a fill just drew a stroked ellipse 8 times getting smaller each time and seems fast enough.
Page Index Toggle Pages: 1