Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2017 02:00
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/8c7c9211e4016636c3a8fe513d9571ae to your computer and use it in GitHub Desktop.
Save anonymous/8c7c9211e4016636c3a8fe513d9571ae to your computer and use it in GitHub Desktop.
/**
* This function draws a randomised set of squares inside each other
* They are of different shapes, colours and strokeweight
* it works with 2 parameters (x and y)
* x: the starting postion of pixels from top left
* y: the starting postion of pixels from top right
* playing with integer size will change position of sqaure
**/
void drawConcentricSquares(float x, float y) {
rectMode(CENTER);
for (int i = 0; i < 100; i = i + 11) {
rect(random(10) + x, random(10) + y, i, i);
if (i%2 == 0) { // if i is even then..
strokeWeight(0.5);
stroke(0); // strokeweight 0.5 in black
} else { // otherwise
strokeWeight(1.3);
stroke((0),random(255),random(255)); // strokeweight 1.3, in random blue or green
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment