Skip to content

Instantly share code, notes, and snippets.

@slambert
Last active February 23, 2018 02:27
Show Gist options
  • Save slambert/8f28af9bf5f3056af675f9cd81f0e643 to your computer and use it in GitHub Desktop.
Save slambert/8f28af9bf5f3056af675f9cd81f0e643 to your computer and use it in GitHub Desktop.
example from class February 21, 2018
/* Function with Return Sketch */
// VARIABLES
color red = color(231, 29, 36);
color orange = color(255, 113, 31);
color yellow = color(255, 255, 31);
color green = color(0, 160, 31);
color blue = color(0, 129, 255);
color purple = color(127, 0, 255);
void setup() {
size(1000, 1000);
strokeWeight(5); // bold!
background(255); // white!
}
void draw() {
stroke(red); // red color
line(pmouseX, pmouseY, mouseX, mouseY); // draw the first line
stroke(orange); //
doubleLine(pmouseX, pmouseY, mouseX, mouseY, 10); // draw the second line
stroke(yellow); //
doubleLine(pmouseX, pmouseY, mouseX, mouseY, 20); // draw the third line
stroke(green); //
doubleLine(pmouseX, pmouseY, mouseX, mouseY, 30); // draw the fourth line
stroke(blue); //
doubleLine(pmouseX, pmouseY, mouseX, mouseY, 40); // draw the fifth line
stroke(purple); //
doubleLine(pmouseX, pmouseY, mouseX, mouseY, 50); // draw the fifth line
//line(x1, y1, z1, x2, y2, z2);
}
// FUNCTIONS
// this draws a line below
void doubleLine(int plineX, int plineY, int lineX, int lineY, int linePos) {
plineY = plineY+linePos; // offset the Y
lineY = lineY+linePos; // offset the other Y
line(plineX,plineY,lineX,lineY); // draw the line
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment