Computer Graphics
Fall 2021
You will be creating a sierpinski carpet fractal as shown below:
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:
a
and b
are vectors and s
is a scaling factorgasket2
example from the textbook code for a usage exampleTRIANGLE_FAN
to make a sqaureYour starter code will be the gasket2
example from the Textbook. You will need to modify the code to make it work for this project.
You will earn up to 30 points for this exercise, broken down as follows:
gl.TRIANGLE_FAN
and FOUR verticesdivideSquare
square
will take four vertices and add a square to the list of vertices to be drawn