Skip to content

Instantly share code, notes, and snippets.

@ff6347
Forked from vogelino/repeatingSize.js
Created July 27, 2016 12:57
Show Gist options
  • Select an option

  • Save ff6347/e177020ae6769447056b5e8cdef15fcc to your computer and use it in GitHub Desktop.

Select an option

Save ff6347/e177020ae6769447056b5e8cdef15fcc to your computer and use it in GitHub Desktop.
var rows = [];
var gridSquareSize = 20;
function setup() {
createCanvas(windowWidth, windowHeight);
rectMode(CENTER);
stroke(255);
var amountOfRows = Math.max(windowHeight / gridSquareSize);
var amountOfColumns = Math.max(windowWidth / gridSquareSize);
for (let rowIndex = 0; rowIndex < amountOfRows; rowIndex++) {
for (let colIndex = 0; colIndex < amountOfColumns; colIndex++) {
var hasStroke = random() > 0.8;
if (rowIndex <= colIndex) {
fill(0);
}
else {
fill(255)
}
var x = gridSquareSize * colIndex + gridSquareSize / 2;
var y = gridSquareSize * rowIndex + gridSquareSize / 2;
strokeWeight(hasStroke ? 1 : 0);
rect(x, y, gridSquareSize, gridSquareSize, (colIndex * rowIndex / 100));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment