58 lines
962 B
Plaintext
58 lines
962 B
Plaintext
|
int numFrames = 50;
|
||
|
int n = 40;
|
||
|
|
||
|
class Tri {
|
||
|
float h, x, y, offset, stroke;
|
||
|
|
||
|
Tri(float h_) {
|
||
|
h = 5*h_;
|
||
|
x = 250;
|
||
|
y = 250;
|
||
|
stroke = random(255);
|
||
|
offset = 9*noise(0.02*x, 0.03*y);
|
||
|
}
|
||
|
|
||
|
void show() {
|
||
|
float x1,y1,x2,y2,x3,y3;
|
||
|
x1 = x + (h/2) + offset;
|
||
|
y1 = y + offset;
|
||
|
x2 = y2 = y - (h/2) - offset;
|
||
|
x3 = x + (h/2) - offset;
|
||
|
y3 = y - (h/2) + offset;
|
||
|
stroke(0, stroke, 0);
|
||
|
line(x1, y1, x2, y2);
|
||
|
line(x2, y2, x3, y3);
|
||
|
line(x3, y3, x1, y1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Tri[] array = new Tri[n];
|
||
|
|
||
|
void setup(){
|
||
|
size(500,500);
|
||
|
|
||
|
for(int i=0;i<n;i++){
|
||
|
array[i] = new Tri(i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void draw(){
|
||
|
background(0);
|
||
|
|
||
|
float t = 1.0*(frameCount-1)/numFrames;
|
||
|
|
||
|
stroke(255);
|
||
|
strokeWeight(6);
|
||
|
|
||
|
translate(width/4,height/6);
|
||
|
for(int i=0;i<n;i++){
|
||
|
rotate(t*sin(TWO_PI/n));
|
||
|
array[i].show();
|
||
|
}
|
||
|
//point(250+50*cos(TWO_PI*t),250+50*sin(TWO_PI*t));
|
||
|
|
||
|
if(frameCount<=numFrames){
|
||
|
saveFrame("fr###.png");
|
||
|
}
|
||
|
}
|