xxxxxxxxxx
static int num=90/3;
static int step=10;
chunk[] ck = new chunk[num];
class chunk {
int x;
int type;
float weight;
float size;
chunk(int n) {
x = n*(90/num);
type = int(random(4));
weight = random(1, 4);
size = random(1, 50);
}
void update(int n) {
x++;
if (x>=90) {
ck[n] = new chunk(0);
}
}
}
void setup() {
size(1024,768);
noFill();
colorMode(HSB, 360, 255, 255);
for (int i=0; i<num; i++) {
ck[i] = new chunk(i);
}
}
void draw() {
background(35);
translate(width/2, height/2);
for (int j=0; j<num; j++) {
int dis = (int)map(sin(radians(ck[j].x)), 0, 1, 1, width/2+100);
float s = ck[j].size;
stroke(255);
strokeWeight(ck[j].weight);
int t = ck[j].type;
for (int i=0; i<360; i+=step) {
stroke(i, 255, 255);
switch (t) {
case 0:
line(dis, 0, dis+s, 0);
break;
case 1:
ellipse(dis, 0, s, s);
break;
case 2:
rect(dis, -s/2, s, s);
break;
default:
triangle(dis, 0, dis+s, -s/2, dis+s, s/2);
}
rotate(radians(step+mouseX));
}
ck[j].update(j);
}
}