Skip to content

Instantly share code, notes, and snippets.

@mactkg
Created July 20, 2015 09:33
Show Gist options
  • Save mactkg/66f99c9563c6a043e14e to your computer and use it in GitHub Desktop.
Save mactkg/66f99c9563c6a043e14e to your computer and use it in GitHub Desktop.
class Jack {
PGraphics g_local, g_global;
Jack() {
g_local = createGraphics(width, height, P3D);
}
void begin() {
g_local.beginDraw();
g_global = g;
g = g_local;
}
void end() {
g_local = g;
g = g_global;
g_local.endDraw();
}
void draw(float x, float y) {
image(g_local, x, y);
}
}
Jack jack;
void setup() {
size(800, 400, P3D);
jack = new Jack();
}
void draw() {
background(0);
jack.begin();
background(128);
fill(255);
translate(width/2, height/2);
rotateY(frameCount/200.);
box(100);
jack.end();
jack.draw(frameCount%width, frameCount%height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment