let points = [];
let numPoints = 1000;
let colors = [];
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
noStroke();
// Pastellfarben
colors = [
color('#524f32'), // Olivgrün
color('#e2c177'), // Beige
color('#e3aa69'), // Pfirsich
color('#e58a56') // Koralle
];
for (let i = 0; i < numPoints; i++) {
points.push(new Point(random(width), random(height)));
}
}
function draw() {
for (let i = 0; i < points.length; i++) {
points[i].move();
points[i].display();
}
}
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
this.size = random(1);
this.col = random(colors);
}
move() {
this.x += random(-2, 2);
this.y += random(-2, 2);
// Grenze überprüfen und zurücksetzen, wenn außerhalb
if (this.x < 0) this.x = 0;
if (this.x > width) this.x = width;
if (this.y < 0) this.y = 0;
if (this.y > height) this.y = height;
}
display() {
fill(this.col);
ellipse(this.x, this.y, this.size, this.size);
}
}