Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2017 01:38
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/23423ffa0c62849e17544e3c4234c8de to your computer and use it in GitHub Desktop.
Save anonymous/23423ffa0c62849e17544e3c4234c8de to your computer and use it in GitHub Desktop.
// This function draws rotated squares
void rotatedRect (int across, int down) {
pushMatrix();
translate(across, down);
float rotation = random(360); // rotation of square is random 360°
rotate(radians(random(360)));
if ( (rotation > 10) && (rotation < 50) ) {
fill(255, 0, 0, 80);
} else { // if rotation is greater than 10° and less than 50°, fill red with 80 transparency
fill(255);
stroke (255, 0, 0, 90); // else white box with red outline with 90 transparency
}
rect(0, 0, 70, 70); // measurements of rectangle
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment