xxxxxxxxxx
let tileSize = 40; // Size of each tile
let cols, rows; // Number of columns and rows in the grid
function setup() {
createCanvas(400, 400);
cols = width / tileSize;
rows = height / tileSize;
noLoop();
}
function draw() {
background(255);
drawTessellation();
}
function drawTessellation() {
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
let x = i * tileSize;
let y = j * tileSize;
// Step 2: Tile the pattern
drawCustomPattern(x, y, tileSize);
}
}
}
function drawCustomPattern(x, y, size) {
// Step 1: Design a unique pattern
fill(random(255), random(255), random(255));
rect(x, y, size, size);
// Step 3: Randomize the grid elements using translate and rotate functions
translate(x + size / 2, y + size / 2);
rotate(random(TWO_PI));
fill(random(255), random(255), random(255));
ellipse(0, 0, size * 0.8, size * 0.8);
// Reset transformations for the next tile
resetMatrix();
}