CS 300

Logo

Computer Graphics
Fall 2021

Sierpinski Carpet Project

You will be creating a sierpinski carpet fractal as shown below:

sierpinski carpet preview

The approach to this project is very similar to the sierpinski gasket triangle example (called gasket2) from the textbook code. The fundamental difference here is we are not thinking about triangles, but squares instead. Much like the triangle, we start with one large square, and then consider what parts of the square need to be drawn, and which are discarded. To do this, each call to divide square must break up the square into 8 equal squares. We don’t keep the center square, as that is discarded. The recursion then takes place on each of the subsquares.

It may help to visualize the process with this illustration.

To help with the fractal, you many want to:

Your starter code will be the gasket2 example from the Textbook. You will need to modify the code to make it work for this project.

Grading

You will earn up to 30 points for this exercise, broken down as follows: