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.
Page Index Toggle Pages: 1
dist() (Read 1462 times)
dist()
May 6th, 2010, 8:32am
 
Is it possible to convert the measurement of dist() which is in pixles to mm?

I am trying to convert the distance of a line, point to point, into a metric measurement.

Thanks

Sam
Re: dist()
Reply #1 - May 6th, 2010, 8:53am
 
It depends on the resolution (in the literal sense) of your monitor...
Ie. if it is 96dpi, 120dpi or something else.
That's dots (=pixels) per inch, so this value provides a base for the answer (you have to convert inches to millimeters, of course).
Re: dist()
Reply #2 - May 7th, 2010, 7:32am
 
Thanks for the help,

Is there a way to detect the users screen resolution?
Re: dist()
Reply #3 - May 7th, 2010, 7:34am
 
Re: dist()
Reply #4 - May 7th, 2010, 7:42am
 
the problem isn't the screen resolution but the monitor! the you could have a 1024x768 screen in a 96dpi monitor or in a 120dpi
Re: dist()
Reply #5 - May 7th, 2010, 8:04am
 
Assuming the device has the same DPI horizontally and vertically (true for most devices, fortunately), you can get it with:
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();

Note that "resolution" is actually measured in DPI. Talking of 1024x768 as screen resolution is an abuse of language, that's actually the screen size...
Re: dist()
Reply #6 - May 7th, 2010, 12:11pm
 
int a = screen.width
int b = screen.height
Page Index Toggle Pages: 1