Last active
October 18, 2016 05:06
-
-
Save LouisStAmour/3fba1ad13745d579ef2f792f3a6b8b37 to your computer and use it in GitHub Desktop.
For DATT 1100 - demonstration of "layering"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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