For this assignment, you are to develop a program that will place trees on the screen, and provide some size and shape information via mouse interaction. The trees should be drawn using a recursive algorithm. The video below shows you how the interface is supposed to work, and what the resulting trees might look like.
To design a tree, the user clicks in four points. The first is where the tree is rooted, the second is at the top of the main tree trunk, the third determines the direction and length of a branch to one side, and the fourth the direction and length of a branch to the other side. When the user presses the left mouse button, a point is displayed as a red dot at the cursor location. As long as the mouse button is held down, this point can be moved around. When the button is released, the point is frozen in place. Each of the four points works in this way, but the 2nd, 3rd, and 4th points are displayed like a rubber band attached to the point they are connected to.
The recursive approach to tree drawing works like this: A tree is a trunk, and two subtrees branching from it. When a subtree is small enough it is simply a leaf, which can be drawn as a circle. The branching angles are determined by the user's mouse clicks of the 3rd and 4th point. The ratio of subtree length to trunk length is determined by the ratio of the lengths of the lines from the top of the trunk to the 3rd and 4th points to the length of the trunk. We will go over this in class, and you can examine this broccoli program example to get a clearer idea of how this should work.
You must write your program in C using EZ_Draw to do the graphics and interaction. Note, that you should now have the ezdraw.h and libezdraw.a files in a separate directory so that they don't need to be copied for every program you build. Refer to the Makefile Lab on Sept. 9. Remember that your program must be compiled and tested on the School of Computing Linux system using your Makefile before turning it in. I cannot support grading programs done in an IDE, since I use scripts to prepare your assignments for testing.
Click here for the grading rubric that will be used.
You are to turn in this assignment via the web interface at: http://handin.cs.clemson.edu.
On this page you will be able to log in, and go to the help pages for all information on how to submit an assignment. Our course is CPSC 1070-001 or CPSC 1070-002. This homework project is called "planting trees" on the course page.
Before turning in your work, please follow these instructions. This is very important, since we process your assignments via an automated script.