This reference is for Processing 2.0+. 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 | ### . (dot)
Examples |
    // Declare and construct two objects (h1 and h2) of the class HLine
    HLine h1 = new HLine(20, 1.0);
    HLine h2 = new HLine(50, 5.0);

    void setup() {
      size(200, 200);
    }

    void draw() {
      if (h2.speed > 1.0) {  // Dot syntax can be used to get a value
        h2.speed -= 0.01;    // or set a value.
      }
      h1.update();  // Calls the h1 object's update() function
      h2.update();  // Calls the h2 object's update() function
    }

    class HLine {  // Class definition
      float ypos, speed;  // Data
      HLine (float y, float s) {  // Object constructor
        ypos = y;
        speed = s;
      }
      void update() {  // Update method
        ypos += speed;
        if (ypos > width) {
          ypos = 0;
        }
        line(0, ypos, width, ypos);
      }
    }
Description | Provides access to an object's methods and data. An object is one instance of a class and may contain both methods (object functions) and data (object variables and constants), as specified in the class definition. The dot operator directs the program to the information encapsulated within an object.
Syntax |
    object.method()
    object.data
Parameters |
object | the object to be accessed
method() | a method encapsulated in the object
data | a variable or constant encapsulated in the object
Related | Object

Updated on May 19, 2014 05:30:05pm PDT