Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2017 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2a0846d2262d80aa5cf2d71504e8f6c9 to your computer and use it in GitHub Desktop.
Save anonymous/2a0846d2262d80aa5cf2d71504e8f6c9 to your computer and use it in GitHub Desktop.
Squares/Jake
/**
* This function draws a series of different squares.
* It takes 2 parameters (x and y) which define
* the position of the square that is drawn.
* x: the distance in pixels from the top left
* y: the distance in pixels from the top right
**/
void DrawSquares(float x, float y) {
noStroke();
for (int i = 0; i < 60; i = i + 5) {
if (i%3 == 0) { // this line says "if i is an odd then..."
fill(0); //fill white
}
else { // otherwise
fill(random (255), random (255), random (255)); //fill in random colour
}
rect(x, y, 60 - i, 60 - i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment