fabianmoronzirfas
7/27/2016 - 12:57 PM

repeatingSize.js

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));
		}
	}
}