Created
March 9, 2016 21:43
-
-
Save sabotai/656147f7b9c243399b07 to your computer and use it in GitHub Desktop.
in-class nested for loops
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
int times = 50; //how many times will we draw each row/column? | |
float dia = 5; //what will the diameter will be | |
void setup() { | |
size(500, 500); //our sketch will be 500 pixels by 500 pixels | |
} | |
void draw() { | |
background(255); //white background | |
for (int col = 1; col < times; col++) { | |
for (int row = 1; row < times; row++) { | |
int x = col * (width / times); //draw whichever column we are currently on in the series and make that a percentage of the width | |
int y = row * (height / times); //do the same for y/height | |
ellipse(x, y, dia, dia); //use our x and y to draw our grid of ellipses | |
fill(x, y, 255); //change the red and green values of our fill along with the x and y positions | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment