Skip to content

Instantly share code, notes, and snippets.

@vogelino
Created July 27, 2016 12:50
Show Gist options
  • Select an option

  • Save vogelino/3d55f0b71d6e8a82c5c62fc9ca4e0486 to your computer and use it in GitHub Desktop.

Select an option

Save vogelino/3d55f0b71d6e8a82c5c62fc9ca4e0486 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