Skip to content

Instantly share code, notes, and snippets.

@LouisStAmour
Last active October 18, 2016 05:06
Show Gist options
  • Save LouisStAmour/3fba1ad13745d579ef2f792f3a6b8b37 to your computer and use it in GitHub Desktop.
Save LouisStAmour/3fba1ad13745d579ef2f792f3a6b8b37 to your computer and use it in GitHub Desktop.
For DATT 1100 - demonstration of "layering"
PGraphics target;
void setup() {
size(500, 400);
target = createGraphics(width, height);
target.beginDraw();
target.background(0);
target.stroke(255);
target.fill(255);
target.ellipse(250, 200, 250, 250);
target.stroke(255, 0, 0);
target.fill(255, 0, 0);
target.ellipse(250, 200, 200, 200);
target.stroke(0, 0, 255);
target.fill(0, 0, 255);
target.ellipse(250, 200, 150, 150);
target.stroke(255);
target.fill(255);
target.ellipse(250, 200, 100, 100);
target.stroke(255, 0, 0);
target.fill(255, 0, 0);
target.ellipse(250, 200, 50, 50);
target.endDraw();
noCursor();
}
void draw() {
image(target, 0, 0);
if (mousePressed) {
stroke(0);
fill(255, 255, 0);
ellipse(mouseX, mouseY, 10, 10);
} else {
stroke(0);
fill(255);
ellipse(mouseX, mouseY, 25, 25);
stroke(0);
line(mouseX-10, mouseY, mouseX+10, mouseY);
stroke(0);
line(mouseX, mouseY-10, mouseX, mouseY+10);
}
}
void mousePressed() {
target.beginDraw();
target.fill(0);
target.stroke(0);
target.ellipse(mouseX, mouseY, 10, 10);
target.endDraw();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment