Created
August 18, 2010 18:53
-
-
Save mataspetrikas/535782 to your computer and use it in GitHub Desktop.
Processing: Babel Tower
This file contains hidden or 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
ArrayList points; | |
int progress = 2; | |
void setup() { | |
size(1200, 800); | |
background(250); | |
smooth(); | |
frameRate(5); | |
points = new ArrayList(); | |
points.add(new Point(width/2, height*0.45)); | |
} | |
void draw() { | |
ArrayList tempP = new ArrayList(); | |
int range = 40 + frameCount; | |
for(int i = 0, l = points.size(); i < l; i++) { | |
Point t = (Point) points.get(i); | |
for(int gi = 0, gl = progress; gi < gl; gi++ ) { | |
Point nuPoint = new Point(random(t.x - range, t.x + range),random(t.y - range, t.y + range)); | |
// add some mutation | |
if(random(100) > 94){ | |
nuPoint.x = random(nuPoint.x-100, nuPoint.x + 100); | |
nuPoint.y = random(nuPoint.y-200, nuPoint.y + 200); | |
} | |
if(abs(nuPoint.y - t.y) < range/3){ | |
nuPoint.y = height - 1; | |
} | |
// if the point is still in the bounds, accept it | |
if((nuPoint.x > 0 && nuPoint.x < width) && (nuPoint.y > 10 && nuPoint.y < height)) { | |
stroke(0, random(50, 150)); | |
line(t.x, t.y, nuPoint.x, nuPoint.y); | |
tempP.add(nuPoint); | |
} | |
} | |
float r = random(5,12); | |
stroke(0); | |
ellipse(t.x, t.y, r,r); | |
} | |
points = tempP; | |
if(points.size() > 35000 || points.size() == 0) { | |
noLoop(); | |
println("finish!"); | |
} | |
else { | |
println(str(frameCount) + '-' + points.size()); | |
} | |
} | |
class Point { | |
float x; | |
float y; | |
Point(float setX, float setY) { | |
x = setX; | |
y = setY; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment