xxxxxxxxxx
44
let moveX = 0; // Variable pour contrôler le déplacement horizontal
function setup() {
createCanvas(windowWidth, windowHeight);
background("#f5f5f5");
fill("#0f0f0f");
stroke("#0f0f0f");
frameRate(7);
}
function draw() {
background("#f5f5f5");
circle(random(100,width), random(100,height), 200);
let spacing = 20;
for (let y = 0; y <= height; y += spacing) {
let x = moveX; // Utilisez moveX pour décaler la position de départ sur l'axe des x
while (x < width) {
let choice = random();
if (choice < 0.5) {
// Dessiner un petit cercle
let circleDiameter = 4;
ellipse(x % width, y, circleDiameter, circleDiameter); // Utilisez % width pour la répétition
x += 8;
} else {
// Dessiner une ligne
let lineLength = random(1, 100);
strokeWeight(1);
line(x % width, y, (x + lineLength) % width, y); // Utilisez % width pour la répétition
x += lineLength + 8; // Ajoutez un espace après la ligne
}
}
}
moveX += 6; // Augmenter moveX pour faire avancer les points
if (moveX > width) { // Réinitialiser moveX pour boucler
moveX = 0;
}
}