xxxxxxxxxx
let cols, rows;
let squareSize = 50;
function setup() {
createCanvas(600, 600);
cols = width / squareSize;
rows = height / squareSize;
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
let variationIndex = int(random(4)); // Generate a random variation index
drawRandomizedPattern(i, j, variationIndex);
}
}
}
function drawRandomizedPattern(i, j, variationIndex) {
let x = i * squareSize + squareSize / 2;
let y = j * squareSize + squareSize / 2;
fill(random(255), random(255), random(255));
// Rastgele konum ve döndürme için translate ve rotate kullanılır
translate(x, y);
for (let k = 0; k < variationIndex; k++) {
rotate(random(TWO_PI)); // Random number of rotations
}
rect(-squareSize / 2, -squareSize / 2, squareSize, squareSize);
// İlk duruma geri dönmek için translate ve rotate sıfırlanır
resetMatrix();
}
function mouseClicked() {
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
let variationIndex = int(random(4));
drawRandomizedCirclePattern(i, j, variationIndex);
}
}
}
function drawRandomizedCirclePattern(i, j, variationIndex) {
let x = i * squareSize + squareSize / 2;
let y = j * squareSize + squareSize / 2;
fill(random(255), random(255), random(255));
// Rastgele konum ve döndürme için translate ve rotate kullanılır
translate(x, y);
for (let k = 0; k < variationIndex; k++) {
rotate(random(TWO_PI)); // Random number of rotations
}
ellipse(0, 0, squareSize, squareSize);
// İlk duruma geri dönmek için translate ve rotate sıfırlanır
resetMatrix();
}