Skip to content

Instantly share code, notes, and snippets.

@mactkg
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mactkg/5bebc794862114bd22c3 to your computer and use it in GitHub Desktop.
Save mactkg/5bebc794862114bd22c3 to your computer and use it in GitHub Desktop.
class Jack {
PGraphics g_local, g_global;
Jack() {
g_local = createGraphics(width, height);
}
void begin() {
g_global = g;
g = g_local;
g.beginDraw();
}
void end() {
g.endDraw();
g_local = g;
g = g_global;
}
void draw(float x, float y) {
image(g_local, x, y);
}
}
Jack jack;
void setup() {
size(800, 400);
jack = new Jack();
}
void draw() {
background(0);
jack.begin();
background(128);
fill(255);
ellipse(width/2, height/2, 50, 50);
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