processingdrawings:
mobile[] mobiles;
void setup() {
size(640, 640);
background(255);
colorMode(HSB);
mobiles = new mobile[0];
for (int b=0; b< 14; b++) {
float ray=(width*0.45-b*14);
float perimetre = 2*PI*ray;
int numba = int(perimetre/20);
float toupiecent=TWO_PI/numba;
float couleur=255/numba;
for (int a=0; a< numba; a++) {
new mobile(width/2+cos(toupiecent*a)*ray, height/2+sin(toupiecent*a)*ray,
color(couleur*a, (255.0/14)*(b+1), 255));
}
}
stroke(0, 100);
}
void draw() {
for (int a=0; a< mobiles.length; a++) {
mobiles[a].draw();
}
}
class mobile {
float x, y, an, v, endx, endy;
float[] vrange;
color c;
mobile(float _endx, float _endy, color _c) {
endx=_endx;
endy=_endy;
c=_c;
x=random(width);
y=random(height);
v=random(0.5, 2.1);
vrange=new float[2];
vrange[0]=random(-0.5, -0.1);
vrange[1]=random(0.1, 0.5);
an=random(TWO_PI);
mobiles = (mobile[]) append (mobiles, this);
}
void draw() {
fill(c);
an+=random(vrange[0], vrange[1]);
x+=cos(an)*v;
y+=sin(an)*v;
if (x<
0||y<
0||x>
width||y>
height) {
an+=random(-PI, PI);
x=constrain(x, 0, width);
y=constrain(y, 0, height);
}
if (random(30)<
1) {
an=atan2(endy-y, endx-x);
vrange[0]=random(-0.5, -0.1);
vrange[1]=random(0.1, 0.5);
}
if (dist(x, y, endx, endy)<
1.7) {
x=endx;
y=endy;
v*=0.97;
}
for (int a=0; a< mobiles.length; a++) {
mobile m=mobiles[a];
if (m!=this) {
float da=dist(m.x, m.y, x, y);
if (da<
10) {
m.x=x+(m.x-x)/da*(da+1);
m.y=y+(m.y-y)/da*(da+1);
}
}
}
ellipse(x, y, 10, 10);
}
}
void keyReleased() {
saveFrame("img#####.png");
}