squareGen: clone of bismuth.garden icon but randomly generated each time

This commit is contained in:
Anish Lakhwara 2020-09-16 23:45:50 +10:00
parent eb5a99b481
commit 3828de6d0b

26
squareGen/squareGen.pde Normal file
View file

@ -0,0 +1,26 @@
int size = 250;
int weight = 20;
int gridSize = 20;
int repetitions = int(random(5));
int dir = int(random(0, 2));
void setup() {
size(500, 500);
}
void draw() {
background(255);
stroke(0);
fill(255);
strokeWeight(weight);
float centerW = (width/2)-(size/2);
float centerH = (height/2)-(size/2);
rect(centerW, centerH, size, size);
strokeCap(SQUARE);
stroke(0);
strokeWeight(weight/2);
//fill(255);
float startX = centerW + weight;
float startY = centerH + weight;
line(startX, startY, startX + (gridSize*repetitions*(1-dir)), startY + (gridSize*repetitions*dir));
}