Created
December 24, 2018 08:35
-
-
Save thepelkus-too/d3fb3c74dff0ba55fff8e09955f6f912 to your computer and use it in GitHub Desktop.
Reimplementation of / variation on thespite's loop 002
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reimplementation of / variation on @thespite's loop 002 | |
// Original src: https://github.com/spite/looper/blob/master/loops/2.js | |
// Original running in browser: https://spite.github.io/looper/#2 | |
int WINDOW_WIDTH = 400; | |
int WINDOW_HEIGHT = 400; | |
float loopDuration = 100.0; | |
void setup() { | |
size(400, 400); | |
background(0); | |
} | |
void draw() { | |
clear(); | |
stroke(255); | |
float cyclicModifier = (float)(frameCount * 2 * Math.PI / loopDuration); | |
float centerRadius = 0; | |
float centerX = WINDOW_WIDTH * .5 + 0 * sin(cyclicModifier); | |
float centerY = WINDOW_HEIGHT * .5 + centerRadius * cos(cyclicModifier); | |
for (int i=0; i<WINDOW_HEIGHT; i+=10) { | |
float lastX = -10; | |
float lastY = i; | |
for (int j=-10; j<WINDOW_WIDTH+10; j+=1) { | |
float dx = j - centerX; | |
float dy = i - centerY; | |
float d = sqrt(sq(dx)+sq(dy)); | |
float sinArg = (float)(.00001 * sq(2.5*d) - cyclicModifier); | |
float expArg = (float)(.00005 * sq(d)); | |
float offset = 16 * sin( sinArg ) * (float)exp( expArg ); | |
float nextX = j; | |
float nextY = i + offset; | |
line(lastX, lastY, nextX, nextY); | |
lastX = nextX; | |
lastY = nextY; | |
} | |
} | |
if(frameCount < 2*loopDuration+2) { | |
saveFrame("output/spitelike_####.png"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment