Last active
August 29, 2015 14:02
-
-
Save josephtaylor/72d28db07ce624d74a7a to your computer and use it in GitHub Desktop.
Processing sketch
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
private ArrayList<Point> points; | |
private final int NUM_POINTS = 20000; | |
private final float NOISE_INCREMENT = 0.03; | |
void setup() { | |
size(700,700); | |
background(255); | |
stroke(0,0,0,10); | |
points = new ArrayList<Point>(); | |
for(int i = 0; i < NUM_POINTS; i++) { | |
PVector loc = new PVector(random(width), random(height)); | |
float r = random(20); | |
float theta = random(2 * PI); | |
//PVector vel = new PVector(r * cos(theta), r * sin(theta)); | |
PVector vel = new PVector(3,3); | |
points.add(new Point(loc, vel)); | |
} | |
} | |
void draw() { | |
for (Point point : points) { | |
line(point.prevLoc.x, point.prevLoc.y, point.loc.x, point.loc.y); | |
point.update(); | |
} | |
} | |
void mousePressed() { | |
saveFrame((int) random(100000000) + ".png"); | |
} | |
public class Point { | |
public PVector loc; | |
public PVector vel; | |
public PVector prevLoc; | |
public float noiseCounter = 0; | |
public Point(PVector loc, PVector vel) { | |
this.loc = loc; | |
this.vel = vel; | |
this.prevLoc = loc.get(); | |
} | |
public void update() { | |
prevLoc.set(loc.x,loc.y,0); | |
float noiseVal = noise(loc.x * NOISE_INCREMENT, loc.y * NOISE_INCREMENT, noiseCounter += NOISE_INCREMENT); | |
float angle = noiseVal * 2 * PI; | |
loc.set(loc.x + (vel.x * cos(angle)), loc.y + (vel.y * sin(angle)), 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment