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)
   help - mouseX / width
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: help - mouseX / width  (Read 206 times)
kevinP

Email
help - mouseX / width
« on: Feb 16th, 2004, 2:31pm »

Help,
 
I'm stuck on something simple. I'm just trying to divide mouseX by the frame width to get a normalized value for mouseX... (but I only get 0.0). I must be doing something stupid I suspect.
 
 
Code:

float nx;
 
void setup()
{
  size(200, 200);
  framerate(5);
}
 
void loop()
{
  nx = mouseX / width;
  println("mouseX=" + mouseX + " width=" + width + " nx=" + nx);
}

 
Outputs: "mouseX=133 width=200 nx=0.0"
« Last Edit: Feb 16th, 2004, 2:32pm by kevinP »  

Kevin Pfeiffer
toxi_
Guest
Email
Re: help - mouseX / width
« Reply #1 on: Feb 16th, 2004, 7:20pm »

that's because you're dividing 2 integers. that should do the trick:
 
Code:
nx=(float)mouseX/width;
 
Pages: 1 

« Previous topic | Next topic »