boolean autoplay = false;
boolean showsFPS = false;
boolean clearsBackground = true;
boolean windEnabled = true;
float lengthDecay = 0.91;
float bloomWidthRatio = 0.6;
float bloomSizeAverage = 15;
float flowerChance = 0.1;
float dx = mouseX - pmouseX;
mouseWindV += dx * mDamp;
mouseWindV += (0 - mouseWind) * wDamp;
if (clearsBackground) background(bgColor);
if (showsFPS) displayFPS();
translate(width/2, height/2);
node = new Node(startLength, startSize, rotRange, 0);
rotRange = random(200, 600);
rotDecay = random(0.9, 1.1);
startLength = random(20, 80);
startSize = random(3, 20);
lengthRand = random(0.0, 0.2);
leafChance = random(0.3, 0.9);
sizeDecay = random(0.6, 0.7);
lengthDecay = map(startLength, 20, 80, 1.1, 0.85);
leafLevel = random(0, 4);
bloomWidthRatio = random(0.9, 0.9);
bloomSizeAverage = random(10, 40);
flowerWidth = random(5, 15);
flowerHeight = random(10, 30);
void randomizeBackground() {
branchHue = random(23, 23);
leafHue = random(23, 23);
leafSat = random(200, 255);
flowerColor = color(33, 11, 99);
if (node) node.randomizeColor();
output += (int) frameRate;
if (key == 'q') showsFPS = !showsFPS;
if (key == 'w') autoplay = !autoplay;
if (key == 'e') clearsBackground = !clearsBackground;
if (key == 'r') windEnabled = !windEnabled;
if (key == 'y') randomizeBackground();
if (key == 'u') randomizeColor();
float flowerScaleT = 1.0;
float flowerBright = 255;
Node(float _len, float _size, float _rotRange, int _level) {
len = _len * (1 + random(-lengthRand, lengthRand));
rot = radians(random(-_rotRange, _rotRange));
if (level < leafLevel) rot *= 0.3;
if (level == 0 ) rot = 0;
windFactor = random(0.2, 1);
if (level >= leafLevel && random(1) < leafChance) doesBloom = true;
bloomSize = random(bloomSizeAverage*0.7, bloomSizeAverage*1.3);
leafRot = radians(random(-180, 180));
flowerScaleT = random(0.8, 1.2);
flowerDelay = round(random(200, 250));
leafDelay = round(random(50, 150));
if (random(1) < flowerChance) doesFlower = true;
float rr = _rotRange * rotDecay;
n1 = new Node(len*lengthDecay, size*sizeDecay, rr, level+1);
n2 = new Node(len*lengthDecay, size*sizeDecay, rr, level+1);
s += (1.0 - s) / (15 + (level*5));
if (level >= leafLevel) stroke(branchColor);
float rotOffset = sin( noise( (float)millis() * 0.000006 * (level*1) ) * 100 );
if (!windEnabled) rotOffset = 0;
rotate(rot + (rotOffset * 0.1 + mouseWind) * windFactor);
leafScale += (1.0 - leafScale) * 0.05;
translate(0, -bloomSize/2);
ellipse(0, 0, bloomSize*bloomWidthRatio, bloomSize);
if (doesFlower && level > levelMax-3) {
flowerScale += (flowerScaleT - flowerScale) * 0.1;
fill(hue(flowerColor), saturation(flowerColor), flowerBright);
ellipse(0, 0, flowerWidth, flowerHeight);
ellipse(0, 0, flowerWidth, flowerHeight);
ellipse(0, 0, flowerWidth, flowerHeight);
branchColor = color(branchHue, random(170, 255), random(100, 200),40);
leafColor = color(leafHue, leafSat, random(100, 255));
flowerBright = random(200, 255);
if (n1) n1.randomizeColor();
if (n2) n2.randomizeColor();