CS 261 Lab F - Fractal Art

Due Wed Mar 05 at 9:00am

Overview

A fractal image is an image in which every small subsection is the same as the larger image it is a part of--if you keep zooming in on the image, you just keep seeing the same thing. These images are defined recursively--each piece of the image contains a copy of itself, and so on.

For example, consider the simple sideways H (It's an H, not an I!) shape labeled Step 1. If you draw similar, but smaller, H shapes at the end of each leg, you get the second shape (Step 2). Continuing that process until the line segments are too small to draw gives you the final shape (Step N).

Step 1
Step 2
Step N

Although this is just a simple example (less than a dozen lines of code), more complicated images can be just as easy. Indeed, simple recursive rules like this can produce all kinds of amazing artwork.

In this lab, you will write programs to draw a pair of simple fractal images. You will draw one of either the above H-Tree or the Sierpinski Triangle, and one of either a fractal tree or the Koch Snowflake.

This lab will be completed in pairs. Review the pair programming guidelines! NOTE: although this lab may lend itself to simply splitting the work in half, you should follow pair programming practices and together write the code for both fractals!

Objectives

Necessary Files

You will need to download the copy of the FractalLab.zip file. This file contains two classes you will need to import into Eclipse. DrawableFrame is a JFrame that you can draw on, such as we have used before. FractalDrawing is an abstract class that you should use as the basis for your own drawings. This class provides functionality to initialize the frame, and provides you with a Graphics object that you can draw on. Do not modify either of these classes, simply use their methods! If you find that you're modifying them to make your code work, then you're doing it wrong!

The FractalDrawing class also has a couple of helpful methods you will want to use. Calling show() will make your drawing so far appear in the frame. Calling wait() will make your program "pause" for a moment. You can use this to slow down the drawing so that you can see what's happening. On my computer, a pause time of 0 milliseconds is instantaneous, and pause time of 5 milliseconds look good on my machine, a pause time of 100 looked good to Dan. Your mileage may vary.

Details

Submitting

Submit your two fractal classes to the LabF submission folder on hedwig. Make sure you upload your work to the correct folder! The lab is due at the start of class on the day after the lab.

Remember to fill out your lab partner evaluation!

The Fractals

The H-Tree

More information about the H-Tree can be found here.

The Sierpinski Triangle

More information about the Sierpinski Triangle can be found here.

The Fractal Tree

More information about the fractal tree can be found here.

The Koch Snowflake

More information about the Koch Snowflake can be found here.

Extensions

You are welcome to implement more than one of these fractals if you have time. There are lots of other amazing fractals out there, including the infamous Mandelbrot Set

Grading

This assignment will be graded based on approximately the following criteria: