Skip to content

Instantly share code, notes, and snippets.

@jacobjoaquin
Created March 16, 2017 14:24
Show Gist options
  • Save jacobjoaquin/b5ea4e1ae251fa30d0b705b70d2e33ea to your computer and use it in GitHub Desktop.
Save jacobjoaquin/b5ea4e1ae251fa30d0b705b70d2e33ea to your computer and use it in GitHub Desktop.
Star Spiral Modulation sketch for Processing 3.
int nFrames = 64;
boolean render = false;
float phaseInc = 1.0 / (float) nFrames;
float phase = 0.0;
void settings() {
size(500, 500);
//pixelDensity(displayDensity());
}
void setup() {
}
void draw() {
translate(width / 2.0, height / 2.0);
background(16);
// Create the blurry layer
stroke(255, 248);
strokeWeight(1.2);
noFill();
blendMode(BLEND);
drawTheSpiral();
filter(BLUR, 2);
// Create the sharp layer
blendMode(ADD);
strokeWeight(1);
drawTheSpiral();
// Update phasor
phase += phaseInc;
if (render) {
saveFrame("./tiff/f######.tiff");
if (frameCount == nFrames) {
exit();
}
}
}
void drawTheSpiral() {
float d = 0; // Distance
float a = 0; // Angle
beginShape();
float thisPhase = phase;
while (d < 400) {
// Modulate the distance
float v = sin(thisPhase * TAU) * 30;
// Create next draw point
PVector p = PVector.fromAngle(a).mult(d + v);
vertex(p.x, p.y);
// Update angle, distance, and phase of modulator
a += TAU / 360.0 + (sin(phase * TAU + d * 0.015) * 0.5 + 0.5) * 0.0005 + 0.00025;
d += 0.05;
thisPhase += 0.04;
}
endShape();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment