/*
Hackpact Arte Generativo 2011
Dia 7
Martin Zumaya Hernandez
*/
Wheel[] wheel;
int N = 2;
float ang = 0.1;
float R = 2;
void setup(){
frameRate(30);
smooth();
colorMode(HSB);
size(700,500);
background(200);
wheel = new Wheel[N];
for( int i = 0; i <N; i++){
wheel[i] = new Wheel();
wheel[i].start();
}
}
void draw(){
fill(200,10);
rect(0,0,width,height);
translate(width/2,height/2);
rotate(ang);
for( int i = 0; i < N; i++){
wheel[i].draws();
wheel[i].w += R*sin(ang);
}
ang += 0.1;
}
void keyPressed() {
if ( key == ' ') {
saveFrame(" #### imagen.png");
}
}
class Wheel {
int N;
float w;
float xc,yc;
float posx[], posy[], velx[], vely[];
color cl;
float r;
Wheel() {
N = 30;
posx = new float[N];
posy = new float[N];
velx = new float[N];
vely = new float[N];
r = random(80, 150);
}
void start() {
noFill();
float tetha = TWO_PI/N;
xc = 0;
yc = 0;
w = r+20;
for ( int i = 0; i < N; i++) {
velx[i] = random(-0.5,0.5);
vely[i] = random(-0.5,0.5);
vely[i] = velx[i];
posx[i] = r*cos(i*tetha);
posy[i] = r*sin(i*tetha);
cl = color(random(180,220),180,180);
}
}
void mmove(float dt) {
for (int i = 0; i < N; i ++) {
posx[i] += velx[i]*dt;
posy[i] += vely[i]*dt;
ellipse(xc + posx[i], yc + posy[i], w, w);
}
}
void draws(){
for( int i = 0; i < N; i ++){
stroke(cl);
ellipse(xc + posx[i], yc + posy[i], w, w);
line(posx[i]+xc, posy[i]+yc, xc, yc);
}
}
};
Spyrograph like, made with circles around a common center with the width varying sinusoidally over time.