Recent Changes - Search:
ECG Home






Spring 2017

Older Courses

Fall 2016

Spring 2016

Fall 2015

Spring 2015

Fall 2014

Spring 2014

Fall 2013

Spring 2013

Fall 2012

Spring 2012

Fall 2011

Spring 2011

Fall 2010

Spring 2010

Fall 2009

Spring 2009

Fall 2008

Spring 2008

Fall 2007


edit SideBar


Recursive Graphics

We'll be implementing the Sierpinski triangle assignment described at

Some notes:

  • You should create a Sierpinski class that derives from sf::Drawable. Then, you can have it just draw itself to your main window. If you are familiar with Java, this would be called “implementing the Drawable interface”:
// instantiate
Sierpinski st(7); // parameter is recursion depth
// maybe want to give it a size parameter too


// later, in the main draw loop
  • Review Jon's LineSegment example to see a simple example of how to do this: Attach:LineDemo.tar.gz.
  • Using SFML's ConvexShape class is a good way to draw a filled triangle.
  • Follow the process advice from the Princeton assignment: “First, make sure that your program draws a single filled equilateral triangle when N equals 1. Then, check that it draws four filled equilateral triangles when N equals 2. Your program will be nearly (or completely) debugged when you get to this point.”
  • Your executable must read two parameters (integers): recursion-depth and window-size. You should create a square SFML window that's exactly as big as the window-size argument, and your triangle should fill it.

What to turn in

It's important that you turn in everything needed to build your projects.

Please note that you will have two projects for this assignment: (1) the Sierpinski implementation and (2) your own original work.

Create a directory with all your work and with both projects in the same directory.

Your Makefile should build both projects. The two resulting executables should be named sierpinski and original. Use unique names for the files in the two projects, so you can put all the files in the same directory.

Each of the two executables should take two arguments:

  1. Recursion depth
  2. Initial window height

Your Makefile should contain two targets: all and clean. The former should build both executables, and the latter should remove the executables, .o files, and all other temporary files created during the build.

The directory should be named ps1 and contain:

  1. Your Makefile
  2. .cpp and .hpp files for both projects
  3. Any images and fonts you are using
  4. Anything else needed to build and run your code
  5. Screenshots of program output for both projects:
    • Your Sierpinski triangle
    • Your original recursive image
  6. A readme.txt file that includes:
    • Your name
    • A discussion of what you did—at least 100 words. What you actually implemented, and, what was interesting, hard, fun, or easy about your project
    • An analysis of how much memory each of the programs uses, depending on the recursion depth:
      • For the data structures (if any)
      • During draw operation (including number of stack frames)
    • How much time you invested (optional)
    • Anything else you'd like us to know (optional)

Remember, we will have to build and run your code, so make sure to submit all that's needed!

Use tar command from the parent directory of your ps1:

 tar czvf <archive-file-name>.tar.gz ps1

to compress your directory structure.

How to turn it in

Submit as follows:
Martin section (201):
Grinberg section (202):

But wait, there's more...

Also, we want you to share your original image with the class.

Post your images to this thread in the discussion group, and write a sentence or two explaining the recursive relationship.

Grading rubric

Sierpinski implementation10full & correct implementation
  1 pt file name correct
  1 pt reads depth and window-size args
  4 pt draws triangles properly
  4 pt implements draw function as derived class of sf::Drawable
original graphic project8full implementation
  1 pt file name correct
  1 pt reads depth and window-size args
  2 pt is somewhat different from Sierpinski project
  2 pt implements draw function as derived class of sf::Drawable
  2 pt screenshot and explanation is posted to course discussion group
Makefile6full & correct implementation
  1 pt builds objects associated with sierpinski project
  1 pt links "sierpinski" executable
  1 pt builds objects associated with original project
  1 pt links "original" executable
  1 pt "make all" builds everything
  1 pt "make clean" removes temporary files, objects, and executables
tar.gz archive2all files packaged in .tar.gz file with correct directory structure
readme.txt4complete and discusses work
Edit - History - Print - Recent Changes - Search
Page last modified on January 29, 2015, at 10:12 PM