Skip to content

Instantly share code, notes, and snippets.

@tinytintoy
Created August 15, 2017 05:03
Show Gist options
  • Save tinytintoy/e51d84a5bd0e92d17cf8d2ee74b147f6 to your computer and use it in GitHub Desktop.
Save tinytintoy/e51d84a5bd0e92d17cf8d2ee74b147f6 to your computer and use it in GitHub Desktop.
float r, theta, drop_speed, dot_size;
PVector center;
ArrayList<Dot> dots;
PImage ref, ref_strip;
void setup(){
size(1280,720);
frameRate(60);
fill(255);
noStroke();
r = height / 2 * 0.8;
drop_speed = float(height) / 6000;
dot_size = 1;//height / 190;
center = new PVector( width/2, height/2 );
dots = new ArrayList();
ref = createImage(width,height/2,RGB);
}
void draw(){
for( int i = 0; i < 60; i++ ){
dots.add(new Dot( center.x + cos(theta) * r, center.y + sin(theta) * r ) );
}
background(0);
for( int i = dots.size() - 1; i >= 0; i-- ){
Dot d = dots.get(i);
d.update();
if(d.kill){
dots.remove(i);
}else{
d.render();
}
}
int split_cnt = 20;
ref = get(0, 0,width,height / 2);
ref_strip = createImage(width, height / 2 / split_cnt, RGB);
for( int i=0; i<split_cnt; i++ ){
ref.filter(BLUR);
pushMatrix();
scale(1,-1);
ref_strip.copy(ref,
0, height / 2 / split_cnt * (split_cnt - i - 1), width, height / 2 / split_cnt,
0, 0, width, height / 2 / split_cnt );
//ref_strip.filter(INVERT);
image(ref_strip,0,-( height / 2 / split_cnt * (i+1) + height / 2));
popMatrix();
}
theta -= 0.009;
theta %= PI;
if( frameCount <= 60 * 60 * 3) saveFrame("images_movie/####.png");
}
class Dot{
int telomere = 200 + int(random(-100,100));
float vy;
PVector loc;
boolean kill;
Dot(float x, float y){
vy = drop_speed * random(0.01,1);
kill = false;
loc = new PVector(x + random(-0.5,0.5),y + random(-0.5,0.5));
}
void update(){
loc.y += vy;
vy *= 1.08;
if( --telomere == 0 ){
kill = true;
}
}
void render(){
noStroke();
pushMatrix();
fill(max(0, min(255,255 * telomere/200)));
rectMode(CENTER);
translate(loc.x, loc.y);
rect(0,0, dot_size, dot_size);
popMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment