GiC (Gestalten in Code) Lang

Back to examples

Groups

Groups thumbnail

Adapted from Groups, created by Fabian Morón Zirfas.

A random choice selects one of six discrete grid scales. Four larger squares form a short diagonal group, demonstrating how similar size makes repeated elements appear related.

// ABOUTME: Fills a regular square grid using one of six random cell sizes.
// ABOUTME: Enlarges four diagonal cells so similarity reveals a distinct group.
// Adapted from Fabian Morón Zirfas's Groups:
// https://github.com/ff6347/gestalten-in-code/tree/e8b8f8446c13c01494ccfd1e92ce2bb1638daf66/grid/processing/groups


background("#ffffff");
fill("#000000");
stroke("#000000");
strokeWidth(0.2);

let choice = floor(random(0, 6));
let step = 1;
if (choice == 1) {
	step = 2;
} else if (choice == 2) {
	step = 4;
} else if (choice == 3) {
	step = 5;
} else if (choice == 4) {
	step = 10;
} else if (choice == 5) {
	step = 20;
}

repeat(x, step, 100, step) {
	repeat(y, step, 100, step) {
		if (x - step == y && x > step * 3 && y < step * 7) {
			rect(x - step / 2, y - step / 2, step, step);
		} else {
			rect(x - step / 4, y - step / 4, step / 2, step / 2);
		}
	}
}