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 & HelpSyntax Questions › floating point pixels
Page Index Toggle Pages: 1
floating point pixels (Read 916 times)
floating point pixels
Mar 21st, 2010, 11:34am
 
Hi,

Just a quick question regarding integer pixel values versus floating point pixel values. If I supply say, (50,50) as parameters to the point function, presumably this addresses this single pixel. But if I use (50.5,50.5), what is this referring to. Is it addressing the RGB elements at a sub pixel level?

Thanks,
Cárthach
Re: floating point pixels
Reply #1 - Mar 21st, 2010, 12:26pm
 
The point function doesn't address a pixel; it plots a point in model-space.  If you haven't done any transformations (e.g., translate(), rotate(), scale() etc) then point(50,50) will indeed plot on the (50, 50)-pixel.  But if you've previously called, say, scale(4,4), then point(50,50) will plot on the (200,200)-pixel, and point (50.5, 50.5) will plot on the (202,202)-pixel.
Re: floating point pixels
Reply #2 - Mar 21st, 2010, 1:30pm
 
Thank you, that makes sense, but if I haven't done any scaling i.e. I've opened a Processing file and just added the following lines

point(50,50);
point(50.5,50.5);

what's the second statement actually referring to?
Re: floating point pixels
Reply #3 - Mar 21st, 2010, 3:33pm
 
I think they refer to the same point: if you don't scale anything, floating point coordinates are just truncated to integer coordinates.
Re: floating point pixels
Reply #4 - Mar 21st, 2010, 5:08pm
 
I thought so too Phil, but when I try it I see two points. It's not a problem, I'm just curious!
Re: floating point pixels
Reply #5 - Mar 21st, 2010, 5:19pm
 
It makes a difference depending on the renderer you use:
Code:
import processing.opengl.*;

size(300,300,P3D); //Try OPENGL, P2D, JAVA2D
//hint(ENABLE_OPENGL_4X_SMOOTH); //This apparently has no effect.
point(50.0,50.5);
point(50.1,51.5);
point(50.2,52.5);
point(50.3,53.5);
point(50.4,54.5);
point(50.5,55.5);
point(50.6,56.5);
point(50.7,57.5);
point(50.8,58.5);
point(50.9,59.5);
point(51.0,60.5);

Re: floating point pixels
Reply #6 - Mar 21st, 2010, 5:38pm
 
carthach wrote on Mar 21st, 2010, 5:08pm:
I thought so too Phil, but when I try it I see two points. It's not a problem, I'm just curious!

What yconst said; in this case it may be rounding 50.5 up to 51.
Page Index Toggle Pages: 1