Skip to content

Instantly share code, notes, and snippets.

@FreedomGrenade
Created April 30, 2016 04:13
Show Gist options
  • Save FreedomGrenade/ba8ef4cd1c26c578bc80b1f700e816cb to your computer and use it in GitHub Desktop.
Save FreedomGrenade/ba8ef4cd1c26c578bc80b1f700e816cb to your computer and use it in GitHub Desktop.
PVector[] pnts;
int[] cols = {#530c0c, #8f0e0e, #fa7e0a, #f7f6de};
public void setup() {
size(540, 540);
pnts = new PVector[5];
for (int i = 0; i < pnts.length; i++) pnts[i] = new PVector();
noSmooth();
loadPixels();
}
public void draw() {
float rot = frameCount*TWO_PI/200.0;
background(255);
for (int p = 0; p < pnts.length; p++) {
float pAng = p*TWO_PI/pnts.length;
pnts[p].z = sin(-rot + 3*pAng)*10;
pnts[p].x = (cos(rot + pAng)/2 + 1)* width/2;
pnts[p].y = (sin(rot + pAng)/2 + 1)* height/2;
}
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float sum = 0;
for (int p = 0; p < pnts.length; p++) {
float dx = pnts[p].x - x;
float dy = pnts[p].y - y;
float d = sqrt(dx*dx + dy*dy);
sum+=(pnts[p].z/max(1, d));
fill(255);
}
sum*=width;
int c = 3;
if (abs(sum) > 120) c = 2;
if (abs( sum + 10 ) < 20) c = 0;
if (abs( sum - 10 ) < 20) c = 3;
if (abs( abs(sum) - 100 ) < 20) c = 1;
pixels[x + y * width] = color(cols[(int)constrain(c, 0, 3)]);
}
}
updatePixels();
if (frameCount < 200) saveFrame("/data/#######.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment