I believe 
             
Processing stores its main graphics window @ variable g.   O_o 
             
 Just check this code and see if you can use var g as argument for your graphics functions later: 
              
             
 
              PGraphics sketch;
void setup() {
    println(g);
    sketch=g;
    println(sketch);
    exit();
}
 
             
 And here's a method called 
             
action() @ class 
             
Particle which draws a pixel into a screen buffer.
             
However, if you call it w/o passing any parameters, its parameterless form calls its parametered one using system variable g!
             
             
The effect of passing variable g is that the pixel is plotted directly to the main 
             
PGraphics buffer, 
             
which is the visible 
             
Processing canvas!
             
             
Of course, g can be passed directly to the parametered form as well:
             
             
              class Particle extends PVector {
    PVector vel;
    Particle(int spd) {
        super( (int) random(width), (int) random(height) );
        vel = new PVector(
        (int) random(2, spd+1) * random(2)<1? -1:1, 
        (int) random(2, spd+1) * random(2)<1? 1:-1);
    }
    void action() {
        action(g);
    }
    void action(PGraphics pg) {
        if (x>width  || x<0)    vel.x *= -1f;
        if (y>height || y<0)    vel.y *= -1f;
        add(vel);
        pg.point(x, y);
    }
}
             
You can check the whole code at this post -> 
             
is-this-a-multythreading-app