For this assignment, you need to write two functions.
public void drawTree( Graphics g, int x, int y )
fillPolygon()) for the branches. You should make it so that
xis the left-most part of the branches, and
yis the tallest part of the tree. You should make each tree relatively small.
public void drawForest( Graphics g, int x, int y, int w, int h )
drawTree()method inside a loop in order to draw many trees within a certain region on the screen. The positions of the trees within the forest should be random, but no part of any tree should extend past the boundaries given.
Once you're done, things should look something like this:
|The diagram to the left is not to scale.|
A tree with a width of 50 and a height of 100 looks like this:
©2013–2015 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.