Last active
March 5, 2019 13:21
-
-
Save jafish/0207b760eae2e54d6f3302da0e3cd5aa to your computer and use it in GitHub Desktop.
Replacing a for loop with a variable that is initialized to zero before the loop and updated within the loop
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
| var y = 0; | |
| //Column Two | |
| for (i=63; i<128; i+=1){ //i variable stands for alpha value | |
| //the loop adds one to the alpha value until it equals 176 | |
| //for (var y=0; y<=630; y+=10){ //y variable stands for the y coordinate of rectangle | |
| //the loop adds 10 to the y coordinate until it equals 630 | |
| fill(255, 0, 0, i); | |
| rect(30, y, 20, 5); //I added 30 to the x coordinate of the rectangle to | |
| //add space between the columns | |
| y+=10; | |
| //} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment