xxxxxxxxxx
44
let angle = 0;
let cellSize;
let clickCount = 0;
let increment = 0.02; // The rate at which the angle changes
let direction = 1; // 1 for increasing, -1 for decreasing
// let capturer = new CCapture({ format: "gif", framerate: 30 });
function setup() {
createCanvas(windowWidth, windowHeight);
// noFill();
fill(80, 210, 150);
strokeWeight(1);
noLoop(); // Stop continuous looping
frameRate(10);
// capturer.start();
}
function draw() {
background(0, 50, 250);
cellSize = min(width / 10, height / 10);
for (let y = cellSize; y < height - cellSize; y += cellSize) {
for (let x = cellSize; x < width - cellSize; x += cellSize) {
push();
translate(x + cellSize / 2, y + cellSize / 2);
let rotateAmount = random(-angle, angle);
rotate(rotateAmount);
square(-cellSize / 2, -cellSize / 2, cellSize);
pop();
}
}
// Gradually increase or decrease the angle based on the direction
angle += increment * direction;
// Change the direction if the angle reaches a certain limit
if (angle >= 0.5 || angle <= 0) {
direction *= -1; // Reverse the direction (increase/decrease)
}
// Loop the drawing process to animate the change
loop();
}