Skip to content

Instantly share code, notes, and snippets.

@jbum
Created April 1, 2015 18:36
Show Gist options
  • Save jbum/f9c97d1d64ce9e1d3072 to your computer and use it in GitHub Desktop.
Save jbum/f9c97d1d64ce9e1d3072 to your computer and use it in GitHub Desktop.
Incremental Drift on 32x32 grid
// Incremental Drift on 32x32 grid - Jim Bumgardner
//
int nbrPoints = 1024;
int cx,cy;
float crad;
float cycleLength, speed;
int startOffset = 0;
int counter =0 ;
boolean isSquare = true;
float secs;
// MovieMaker mm;
void setup()
{
if (isSquare)
size(720+16,720+16);
else
size(1280, 720);
cx = width/2;
cy = height/2;
crad = (min(width,height)/2) * 0.95;
noStroke();
smooth();
colorMode(HSB, 1);
ellipseMode(RADIUS);
background(0);
cycleLength = 3*60*30;
frameRate(30);
speed = (2*PI*nbrPoints) / cycleLength;
}
void draw()
{
background(0);
float timer = (frameCount+startOffset)*speed;
for (int i = 0; i < nbrPoints; ++i)
{
float r = 1 - i/(float)nbrPoints;
float a,len,rad;
a = timer * r;
len = i*crad/(float)nbrPoints;
rad = max(1,len*.025);
float lum = (sin(a)+1)/2;
// float hue = frameCount/(float)cycleLength;
float hue = r + timer * .01;
hue -= int(hue);
float x = (i % 32) * (width/32.0);
float y = (i / 32) * (width/32.0);
// fill(hue,.5,.5+lum*.5);
fill(hue,.5,lum);
rect(x,y,width/32.0,width/32.0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment