Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
int gap = 20;
void setup() {
size(1000, 1000);
strokeWeight(4);
strokeCap(SQUARE);
frameRate(0.5);
}
void draw() {
background(204);
drawPattern(0);
drawPattern(random(TWO_PI));
}
void drawPattern(float angle) {
pushMatrix();
translate(width/2, height/2);
rotate(angle);
int rowCount = 0;
for (int y = -300; y <= 300; y += gap*2) {
for (int x = -300; x <= 300; x += gap) {
if (rowCount % 2 == 0) {
line(x, y, x, y + gap*2);
} else {
line(x+gap/2, y, x+gap/2, y + gap*2);
}
}
rowCount++;
}
popMatrix();
saveFrame();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment