FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Don't understand screenX(...)
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Don't understand screenX(...)  (Read 413 times)
mad


Don't understand screenX(...)
« on: Jan 31st, 2005, 3:55am »

In a 2D application, each object draws itself at (0, 0) and uses translate to place its parts.  I thought I could use screenX() and screenY() to recover coordinates compatible with mouseX and mouseY for picking.  It doesn't work like that, though.  Would someone please explain screenX(), and suggest a way to do picking?
 
I expected the following program to print
 
0 0
20 20
40 40
60 60
80 80
 
but it prints
 
0 -0.5841017
20 19.290798
40 60.35884
60 123.389725
80 209.19089
 
void draw() {
for (int a=0; a<width; a+=20) {
    translate(a, 0);
    println(a + " " + screenX(0, 0, 0));
}
}
 
p5 0068  
Win2000 SP4 on p3 Mobile  
 
 
mad


Re: Don't understand screenX(...)  -- read this ve
« Reply #1 on: Jan 31st, 2005, 4:01am »

In a 2D application, each object draws itself at (0, 0) and uses translate to place its parts.  I thought I could use screenX() and screenY() to recover coordinates compatible with mouseX and mouseY for picking.  However they don't quite match up.  Would someone please explain screenX(), and suggest a way to do picking?  
 
I expected the following program to print  
 
0 0  
20 20  
40 40  
60 60  
80 80  
 
but it prints  
 
0 -5.9604645E-6
20 19.649542
40 39.7636
60 60.35884
80 81.452736
 
 
void draw() {
for (int a=0; a<width; a+=20) {
    println(a + " " + screenX(0, 0, 0));
    translate(20, 0);
}
}
 
p5 0068  
Win2000 SP4 on p3 Mobile  
 
 
fjen

WWW
Re: Don't understand screenX(...)
« Reply #2 on: Jan 31st, 2005, 4:05am »

forum search came up with this:
screenx, screeny (screenz )
 
/F
 
Pages: 1 

« Previous topic | Next topic »