trees06

Launch Java Applet: trees06. (runs at 1024×1024)

See a pile more pics of this sketch over on Flickr.

I’m not sure what my fascination with rendering trees in Processing is. But I sure seem to spend a lot of time on it :)

This sketch is an advancement of my scribble04 sketch.  I took the concept of an object drawing a line, and simply had it conform to more rules.  The past sketch I did on trees (trees03) was all function based, so I consider this sort of an evolution of my tree code 😉

If you run the example, it will consistently run a certain set of rules.  But if you download the source, you’ll see there are many variables exposed to the user, here’s a snippet from the sketch:

// what is the birth position, based on a percentage of screen size?
float initX = .5;
float initY = 1;

// How long is the initial branch in pixels?
float initLength = 20;
// as it grows, scale the length between steps by this value
float lengthAgeScale = .98;

// How can a trunk differ in direction direction from it's parent?
float angleRand = radians(5);
// angle in radians:  PI = 180 deg.
float initAngle = random(-HALF_PI-angleRand, -HALF_PI+angleRand);

// what is the initial size of the branch (first trunk):
float branchSize = 200;
// for each groth, how much smaller does the trunk get:
float branchAgeScale = .95;

// For a NEW branch, define a range of angles relative to its parent angle to be grown in.  The
// values can be for either side of the branch, randomly picked at birth. 0 = same angle as its parent.
// HALF_PI = (90 deg) would be perpendicular to its parent.  So, {HALF_PI, 0} would be a
// 180 deg arc based on it's current angle (since it will randomly choose to grow off of either side.
float[] branchAngleRange = {radians(45), 0};

// for each growth period, what is the percent chance (from 0->100) that
// a new branch will be formed?
float branchPercent = 10;
// as a trunk gets older, multiply its branchPercent by this value.
float branchAgePercentChange = .99;

// What is the initial brightness:
float bright = 0.0;
// for each groth, how should the brightness be scaled?
float brightnessScale = 1.0;
// for each grown, what value should be added to brightness?
float brightAdd = 2;

// How strong is the force that makes the branches want to grow "up"?
float upStrength = 1;
// How strong is the force that bends the branches down?  Force is very weak near the roots,
// and gets progressively stronger towards the tips.
float gravityStrentgh = 5;
    • DarenGMcDougal
    • November 9th, 2011 10:58pm

    Great post.I like this site.Thanks a lot for the sketch on Flickr.

    • temach
    • December 27th, 2013 2:43am

    Seriously awesome stuff.

  1. No trackbacks yet.