Computer Graphics Asst5
Iterated Function Systems (IFS)

Team Member

Zihan Yan:
Haojun Lu:


This is the last assignment for CMU 15462/15662 Computer Graphics.
In the final project ,we have implemented Iterated Function Systems.

The main idea is to start with a point and then repeatedly rasterize the point and then apply a distribution of affine transformations to it. We have successfully modified Assignment 1 code to rasterize two classical IFS, Sierpinski triangle and Barnsley Fern.

Furthermore, we extended our code to be compatible of other type of files and designed our own IFS. Details are presented in later sections.

The fractal is an interesting way to show infinite detail! In this assignment we have designed and rendered beautiful fractals using Iterated Function Systems (IFS).

What We Have Done

Most changes to A1 is made in hardware_renderer.cpp

1. We have modified our A1 code so that it can correctly render IFS.

2. We have implemented SVG files generators for fractals. As a result, our program can generate a SVG file based on the current rendered image and others can re-render it. (Generated files are like the tree in this website)

3. Without loading an existing SVG image to render, our program can draw nice IFS built-in images and switch between them in different modes.(More on User guide)

4. We have designed our own IFS and a file format which contains some parameters to draw awesome IFS images. Our program now can read parameters from this file format and render different IFS images based on these.
The program will load a file called 1.ifs. So please put the 1.ifs file, which is in the asst5 folder, in the same folder as drawsvg.
Actually it is a csv (Comma-Separated Values) file with seven columns.
For IFS, the transformation is


The first 4 columns are the 4 elements in A ( top left, top right, bottom left, bottom right).
The next 2 columns are the elenments in B.
The last column is the CFD (Cumulative Distribution Function), which means it is the sum of the pdf of this column and previous columns. It should increase row by row and the last one should be 1.

This is the 1.ifs in my foler. It will generate something like a snowflake.It is obtained when we change Sierpinski Triangle's IFS, turn 0.5 in A to -0.5. You can modify yours as long as the format is satisfied.

-0.5,0 , 0, -0.5 , 1.3 ,1 , 0.333333
-0.5,0 , 0, -0.5 , 2.3 ,4 , 0.666667
-0.5,0 , 0, -0.5 , -2.3, 2 , 1

5. We have implemented a distance buffer so that our background color can be dynamically changing based on IFS we have drawn.
It is also very flexible because you can use any kind of mapping function to change the background color however you like, since the distance buffer has been here for you.

6. Finally, the coolest part of our last assignment is the Fractal Flame we have created. They are fantastic dynamic fractal series! Screenshots can not display its beauty, try it out!

User Guide

First you can find our code in afs and copy everything there to your folder:


Second, run the following command to build it correctly.

cd CG_asst5 && mkdir build && cd build

Then run

cmake ..

After that, please run


Do please put the 1.ifs file, which is in the asst5 folder, in the same folder as drawsvg.
This is a file for IFS, which is explained in What We Have Done.

To see our built in IFS, you can run the following code:

./drawsvg ../svg/basic/test6.svg
(You can use any svg files, results turned out to be same for built-in IFSs.

Now you need to switch to Hardware Renderer Mode by Cliking "h" or "H"

Now you are under Hardware Renderer Mode, Clicking "i" will direct to built-in IFS images.

Get bored? Try clicking "w" multiple times to switch between different IFS images.(Several built-in and one from 1.ifs)

If you are ready for the coolest Fractal Frames, click "f".

You are also allowed to switch frames by clicking "w".

For the SVG files generator, enter matlab folder. Run run_draw_frac.m in Matlab and fractal.svg will be created.

Here is a wrap up!

h                    switch to hardware renderer mode
i                     switch to built-in IFS images
w                   switch between different IFS images or Fractal Frames.
f                     switch to Fractal Frames

Enjoy it!

Any Questions or Problems?

Please contact us at:
Zihan Yan:
Haojun Lu:


For the csv file reader, we use fast-cpp-csv-parser.
This assignment is based on CMU 15462/15662 Computer Graphics asst1.