Skip to content

Instantly share code, notes, and snippets.

@jacobjoaquin
Created October 29, 2014 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobjoaquin/e24f71b8375d54a8d558 to your computer and use it in GitHub Desktop.
Save jacobjoaquin/e24f71b8375d54a8d558 to your computer and use it in GitHub Desktop.
Pac Illusion
float phasor = 0.0;
float phasorInc = 0.001;
float nFrames = 45;
void setup() {
// size(500, 500, "processing.core.PGraphicsRetina2D");
size(500, 500);
phasorInc = 1 / nFrames;
}
void draw() {
background(0);
fill(255, 255, 0);
int nPacs = 13;
float s = 1.0 / float(nPacs);
translate(s * width * 0.5, s * height * 0.5);
for (int y = 0; y < nPacs; y++) {
for (int x = 0; x < nPacs; x++) {
pushMatrix();
translate(float(x) / float(nPacs) * width, float(y) / float(nPacs) * height);
scale(s * 0.5, s * 0.5);
float d = dist((nPacs - 1) * 0.5, (nPacs - 1) * 0.5, x, y);
d = map(d, 0, nPacs * 0.5, 0, 1.0);
pac(phasor + d);
popMatrix();
}
}
phasor += phasorInc;
if (phasor >= 1.0) {
phasor -= 1.0;
}
// saveFrame("f####.gif");
// if (frameCount == nFrames + 1) {
// exit();
// }
}
void pac(float phase) {
float maximum = PI;
float amount = map(sin(phase * TWO_PI), -1.0, 1.0, 0, maximum);
arc(0, 0, width, height, amount, TWO_PI - amount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment