pmouseX \ Language (API) \ Processing 1.0
Author: Casey Reas & Ben Fry
Description: Processing is an electronic sketchbook for developing ideas. It is a context for learning fundamentals of computer programming within the context of the electronic arts.
Keywords: Processing, Processing, Interactive Media, Electronic Arts, Programming, Java, Ben Fry, Casey Reas

Reference for Processing version 1.5. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name | ### pmouseX
Examples |
    // Move the mouse quickly to see the difference
    // between the current and previous position
    void draw()
    {
      background(204);
      line(mouseX, 20, pmouseX, 80);
    }
Description | The system variable pmouseX always contains the horizontal position of the mouse in the frame previous to the current frame. You may find that pmouseX and pmouseY have different values inside draw() and inside events like mousePressed() and mouseMoved(). This is because they're used for different roles, so don't mix them! Inside draw(), pmouseX and pmouseY update only once per frame (once per trip through your draw()). But, inside mouse events, they update each time the event is called. If they weren't separated, then the mouse would be read only once per frame, making response choppy. If the mouse variables were always updated multiple times per frame, using line(pmouseX, pmouseY, mouseX, mouseY) inside draw() would have lots of gaps, because pmouseX may have changed several times in between the calls to line(). Use pmouseX and pmouseY inside draw() if you want values relative to the previous frame. Use pmouseX and pmouseY inside the mouse functions if you want continuous response.
Syntax |
    pmouseX
Usage | Web & Application
Related | pmouseY mouseX mouseY

Updated on August 30, 2010 04:29:39pm EDT