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

### this

Examples

    float ypos = 50;

    void setup() {
      size(100, 100);
      noLoop();
    }

    void draw() {
      line(0, 0, 100, ypos);
      this.ypos = 100;
      line(0, 0, 100, ypos);
    }

    import processing.video.*;
    Movie myMovie;

    void setup() {
      size(200, 200);
      background(0);
      myMovie = new Movie(this, "totoro.mov");
      myMovie.loop();
    }

    void draw() {
      if(myMovie.available()) {
        myMovie.read();
      }
      image(myMovie, 0, 0);
    }

Description

Refers to the current object (i.e. "this object"). In Processing, it's most common to use this to pass a reference from the current object into one of the libraries. The keyword this can also be used in another way, but it is often not necessay. For example, if you are calling the filter() method of a PImage object named tree from another object, you would write tree.filter(). To call this method inside PImage itself one could simply write filter() or could more explicity write this.filter(). It's not incorrect to say this.filter() but it is not necessary as this is always implied.

Usage | Web & Application

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