Skip to content

Instantly share code, notes, and snippets.

@osteele
Last active October 30, 2020 10:20
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 osteele/4da0a93457a254969d9116e97dc16b2f to your computer and use it in GitHub Desktop.
Save osteele/4da0a93457a254969d9116e97dc16b2f to your computer and use it in GitHub Desktop.
/* A reproduction, with modification, of a work by Vera Molnar.
* Author: Oliver Steele
* Source: https://gist.github.com/osteele/4da0a93457a254969d9116e97dc16b2f
* This work is licensed under a Creative Commons Attribution 4.0 International License.
*/
final int size = 100;
final int displacement = 6;
void setup() {
size(800, 600);
}
void draw() {
randomSeed(1);
background(255);
noFill();
for (int x = 0; x < width; x += size) {
for (int y = 0; y < height; y+= size) {
push();
translate(x, y);
drawSquare();
pop();
}
}
}
void drawSquare() {
int margin = 0;
for (int i = 0; i < 8; i++) {
int width = size - margin;
int height = size - margin;
push();
fill(255);
if (random(10) <= 1) {
fill(random(255));
}
if (i == 7 && random(10) <= 1) {
fill(random(255), random(255), random(255));
}
beginShape();
vertex(margin + random(displacement), margin + random(displacement));
vertex(width - random(displacement), margin + random(displacement));
vertex(width - random(displacement), height - random(displacement));
vertex(margin + random(displacement), height - random(displacement));
endShape(CLOSE);
pop();
margin += random(3, 6);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment