Generative Art - Assignment twelve

Due: 2014-01-27 10:30a

Objectives

[15 points] Fractal trees

For this assignment, I want you to make some refinements to the fractal tree we looked at in class.

Assignment12

First modification

Make the thickness of the trunk and the branches different. At its simplest, this could just mean make the stroke weight a function of len. This could be a simple linear function (like the weight is a percentage of the len – this is what is seen above), or you could come up with some kind of exponential or logarithmic function to tapper off more quickly or slowly. Tinker with it until it looks reasonable.

Second modification

Use noise() to control the angles of the branches. Keep theta and -theta, just add a noise factor to them. In my example above, I used theta as the range and an offset of theta/2 (in other words, the angle could vary from the original angle by as much as theta/2 in either direction).

To control the noise, add two properties to the Tree. Add a float variable called noiseVariable and a float variable called noiseStep. noiseVariable will be the value you pass into the the noise() function. Each time after you use noise() add noiseStep to noiseVariable. Experiment with the value you put in noiseStep, but start small (e.g., 0.005).

Once you have done this, if you run your sketch, you will find that the tree shakes and shimmies all over the place. This is because the frame loop is redrawing the tree over and over and each time the random amounts are different. We can stop this by creating a third property in the Tree class called noiseStart. Set this to 0. Each time before you paint call branch() in the paint() function, set noiseVariable = noiseStart. This will reset your position on the noise curve.

Run the program again and make sure your tree is now still. Now that it is still, we are going to make it move again, but in a more controlled fashion. Right after you use noiseStart to initialize noiseVaraible, add the noiseStep to it. This will mean that the next time you draw the tree, you will be one step further along the noise curve for every angle you calculate. As you will see, the result of this is that you tree will appear to be blowing in the wind (something not captured by my screenshot above).

Take it all a little further

There are a number of things that you could play with here. Add some color. Maybe make the color dependent on where you are in the tree. You could add leaves – when the branches get to a certain length draw some leaves on instead. Add more randomness. Vary the lengths of the branches or the number of branches (you may want to use random for this, rather than noise, otherwise your tree may sprout branches as it waves back and forth). One of the advantages of the Tree class is that you can make as many trees as you like. Make a forest or a landscape picture. Have fun.

Naming your sketch

I would like you to name the sketch using this pattern: username_hw12.

Take a picture

Submit at least one image and name it using the pattern username_hw12-####.png.

Documentation

Don’t forget the documentation block below at the top of your sketch. Make sure that you specify what you did that was cool and interesting.

/**
Assignment Twelve

A description of the sketch.

Your name
The date
**/

Turning in your work

I would like this code turned in in the DROPBOX on MiddFiles. You can refer to the reference on the LIS wiki to help you connect to the file server.