Created
February 14, 2018 17:10
-
-
Save slambert/43f72353f8e7b85dba382b5bb1de832d to your computer and use it in GitHub Desktop.
for and while loop demo 2018
This file contains hidden or 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
/* | |
/ Steve Lambert February 14, 2018 | |
/ Valentimes! | |
/ for and while loop demo v1 | |
*/ | |
color romanceRed = color(196,10,10); | |
color cupidPink = color(255,129,129); | |
void setup() { | |
size(500,500); | |
background(romanceRed); | |
smooth(); | |
strokeWeight(5); | |
frameRate(1); | |
} // end setup | |
void draw() { | |
background(romanceRed); | |
// This is a while loop | |
stroke(cupidPink); // While style is PINK! | |
//start with i as 0 | |
int i = 0; | |
//while i is less than the width of the window | |
while(i < width ){ | |
line(i,20,random(0,width),200); | |
//i++; | |
i = i + 20; | |
println("while i = " + i); | |
} | |
// This is a for loop | |
stroke(255); | |
// This is a for loop | |
for (int b = 0; b < width; b += 20){ | |
line(b,250,b,450); | |
println("for b = " + b); | |
} // end for loop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment