Created
January 19, 2017 17:27
-
-
Save daneden/be9148c709ed7e1c58356c11cd3cbaff 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
// F E I G E N B A U M | |
// G R O W T H | |
float f = 3; // we have to start with some kind of seed, and ~3.4 is where things get interesting | |
float x = -2; // start it a little off screen | |
float y = 0.85; // again, a seed value is needed to actually see anything | |
void setup() { | |
size(800,800); | |
pixelDensity(displayDensity()); | |
smooth(); | |
background(255); | |
} | |
void draw() { | |
for(int i = 0; i < 10; i++) { // draw 10 points at once so that it doesn't take forever | |
pushMatrix(); | |
translate(0, height*0.1); | |
stroke(#E05362); | |
// the formula is expressed as: | |
// b = f * a * (1-a) | |
// where 'b' is the next generation, 'a' is the current generation, and 'f' is the growth rate/fertility | |
y = f * y * (1-y); | |
point(x, y*(height*0.7)); | |
f += 0.000009; | |
x+=0.0075; | |
popMatrix(); | |
if(Double.isInfinite(y)) { // end the loop if we reach infinity | |
noLoop(); | |
println("infinity reached"); | |
break; | |
} | |
if(x == width) { | |
noLoop(); | |
break; | |
} | |
} | |
} | |
void mousePressed() { | |
saveFrame("export-####.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment