Kreise [] k = {};
int num = 20;
void setup(){
frameRate(24);
size(550,550);
background(0);
smooth();
noStroke();
drawKreise();
}
void draw(){
noStroke();
fill(0,25);
rect(0,0,width,height);
for(int i=0;i<k.length; i++){
Kreise thisKreise = k[i];
thisKreise.update();
}
}
void drawKreise(){
for(int i=0; i<num; i++){
Kreise thisKreise = new Kreise();
thisKreise.drawMe();
k = (Kreise[])append(k, thisKreise);
}
}
class Kreise {
float x, y;
float rad;
float colR, colG, colB;
float vRad = 2;
boolean richtung = true;
int radMax = 250;
Kreise() {
x = random(5, width-5);
y = random(5, height-5);
rad = random(5, radMax);
colR = x*255/width;
colG = y*255/height;
colB = x+y;
}
void update() {
if (richtung == true) {
rad +=vRad;
if (rad > radMax) {
richtung = false;
}
}
else {
rad -= vRad;
if (rad < 0) {
richtung = true;
}
}
noFill();
strokeWeight(4);
stroke(colR, colG, colB,200);
ellipse(x, y, rad, rad);
}
void drawMe() {
noFill();
stroke(colR, colG, colB);
ellipse(x, y, rad, rad);
}
}