Created
December 22, 2016 00:34
-
-
Save jmorrow1/0f3bbbe5d8388a8ab1d8f6e27eb06787 to your computer and use it in GitHub Desktop.
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
import paths.*; | |
import paths2.*; | |
import tracer.*; | |
import ease.*; | |
import render.*; | |
//Grids of circles w/in grids of circles => One tracer per circle => RenderMesh | |
//1. Create paths | |
//2. Trace paths with tracers | |
//3. Draw tracers with Renders | |
//paths | |
float minRadius = 10; | |
float startRadius = 100; | |
ArrayList<Tracer> tracers = new ArrayList<Tracer>(); | |
float du = 0.0001; | |
ArrayList<Path> paths = new ArrayList<Path>(); | |
//render | |
RenderMesh render; | |
float minDist = 1, maxDist = 40; | |
//style | |
int bgColor = #ffffff; | |
int fgColor = #111111; | |
//time | |
int prevt; | |
void settings() { | |
size(400, 400); | |
} | |
void setup() { | |
createPaths(width/4, height/4, startRadius, minRadius, true); | |
createPaths(3*width/4, height/4, startRadius, minRadius, true); | |
createPaths(3*width/4, 3*height/4, startRadius, minRadius, true); | |
createPaths(width/4, 3*height/4, startRadius, minRadius, true); | |
createTracers(); | |
render = new RenderMesh(tracers, 20); | |
render.setStrokeColor(fgColor); | |
render.setStrokeRamp(maxDist); | |
render.setStrokeWeight(1.5f); | |
} | |
void createPaths(float x, float y, float r, float minRadius, boolean skip) { | |
if (!skip) { | |
Path path = new Circle(x, y, r); | |
paths.add(path); | |
} | |
float newR = r/2; | |
if (newR >= minRadius) { | |
float newX = x - newR; | |
for (int i=0; i<2; i++) { | |
float newY = y - newR; | |
for (int j=0; j<2; j++) { | |
createPaths(newX, newY, newR, minRadius, false); | |
newY += r; | |
} | |
newX += r; | |
} | |
} | |
} | |
void createTracers() { | |
for (Path p : paths) { | |
float speed = random(-du, du); | |
//float speed = (random(1) < 0.5) ? -du : du; | |
Tracer t = new Tracer(p, random(1), speed, new Easing() { | |
public float val(float t) { | |
return t; | |
} | |
}); | |
tracers.add(t); | |
} | |
} | |
void draw() { | |
int dt = prevt - millis(); | |
prevt = millis(); | |
float t = millis() / 20000f; | |
float rads = t * TWO_PI; | |
float dist = map(sin(rads), 0, 1, minDist, maxDist); | |
render.setMinDist(dist); | |
background(bgColor); | |
//draw paths | |
//stroke(100); | |
//strokeWeight(1); | |
//noFill(); | |
//for (Path p : paths) { | |
// p.draw(g); | |
//} | |
//draw renders | |
render.step(dt); | |
render.draw(g); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment