Skip to content

Instantly share code, notes, and snippets.

@osdrv
Created January 11, 2012 13:10
Show Gist options
  • Save osdrv/1594588 to your computer and use it in GitHub Desktop.
Save osdrv/1594588 to your computer and use it in GitHub Desktop.
processing document object model
import processing.opengl.*;
import document_object.*;
Window window;
void setup() {
this.window = new Window( this, 640, 480, OPENGL );
background( 0 );
MyDocumentObject o = new MyDocumentObject( this );
window.appendChild( o );
}
void draw() {
window.render();
}
class MyDocumentObject extends DocumentObject {
public MyDocumentObject( PApplet p ) {
super( p );
this.setDim( 50, 50 );
this.setPos( 10, 10 );
}
void render() {
getApplet().rect( this.getPosX(), this.getPosY(),
this.getWidth(), this.getHeight()
);
super.render();
}
void onMouseClick( CatchableMouseEvent e ) {
println( "child element captured click!" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment