sketch/cosfunc1/sketch_1/sketch_1.pde
2018-07-11 23:22:22 +10:00

52 lines
1.2 KiB
Plaintext

int numFrames = 75;
int m = 8000;
float delay = 10;
void setup(){
size(500,500,P3D);
stroke(255);
fill(255);
}
float x1(float t, int offset){
return offset + 0.5*width + 500*cos(TWO_PI*t);
}
float y1(float t, int offset){
return offset + 0.5*width + -500*cos(2*TWO_PI*t);
}
float x2(float t, int offset){
return offset + 0.5*width + -500*cos(TWO_PI*t);
}
float y2(float t, int offset){
return offset + 0.5*height + 500*cos(2*TWO_PI*t);
}
void draw(){
float t = 1.0*(frameCount - 1)/numFrames;
background(0);
//int[] Xoffset = {-25, 0, 25};
//int[] Yoffset = {0, 5, 10};
//for (int i = 0; i < 3; i++) {
ellipse(x1(t,0 ),y1(t,0 ),6 , 6);
ellipse(x2(t,0 ),y2(t,0 ),6 , 6);
pushStyle();
strokeWeight(2);
stroke(255,100);
for(int i=0;i<=m;i++){
float tt = 1.0*i/m;
float x = lerp(x1(t - delay*tt,0),x2(t - delay*(1-tt),0),tt);
float y = lerp(y1(t - delay*tt, 0),y2(t - delay*(1-tt),0),tt);
point(x,y);
}
popStyle();
//}
//ellipse(x2(t),y2(t),6,6);
println("saving frame " + frameCount + "/" + numFrames);
if(frameCount<=numFrames) saveFrame("fr###.png");
if(frameCount == numFrames) stop();
}