sketch/unsatisfying/unsatisfying.pde
2020-03-25 23:01:04 +11:00

74 lines
1.4 KiB
Plaintext

int samplesPerFrame = 5;
int numFrames = 500;
float shutterAngle = 1.5;
boolean recording = true;
int n = 1000;
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
else
return 1 - 0.5 * pow(2*(1 - p), g);
}
class Thing{
float size = random(1,15);
float offset = random(0, 0.6);
float theta;
float de = random(5, 20);
Thing(float theta_){
theta = theta_;
}
void show(){
stroke(255,100);
strokeWeight(size);
float t = 1.0*(frameCount-1)/numFrames;
float t2 = ease(t, 8);
float radius = 150 + 200*sin(TWO_PI*t2 + offset);
// right side
float x = 250 + radius*cos(theta)*cos(theta) + noise(0.04);
float y = 250 + radius*sin(theta) + noise(0.02);
point(x, y);
// left side
// throw on an easing function or delay here?
float x2 = 250 - radius*cos(theta)*cos(theta) + noise(0.04);
float y2 = 250 - radius*sin(theta) + noise(0.02);
point(x2, y2);
}
}
Thing[] array = new Thing[n];
void setup(){
size(500, 500, P3D);
for(int i=0;i<n;i++){
float theta = TWO_PI*i/n;
array[i] = new Thing(theta);
}
}
void draw(){
background(0);
float t = 1.0*(frameCount-1)/numFrames;
stroke(255 * sin(TWO_PI*t), 0 * cos(TWO_PI*t), 255 * cos(TWO_PI*t));
strokeWeight(10 + 10*sin(TWO_PI*t));
point(250,250);
for(int i=0;i<n;i++){
array[i].show();
}
if (frameCount<=numFrames){
saveFrame("fr###.png");
}
}