Final Project for CSCI200
  • C++ 98.2%
  • Makefile 1.8%
Find a file
2026-09-04 23:34:15 -06:00
inc Implemented my own linked list 2026-09-04 19:35:12 -06:00
proposal Proposal 2026-08-31 15:35:10 -06:00
samples Another loads of shapes sample. This time bigger. 2026-09-04 19:38:43 -06:00
src Duplicate print 2026-09-04 19:41:08 -06:00
.gitignore Added gitignore 2026-09-04 17:26:04 -06:00
Makefile Makefile improvements 2026-09-04 19:45:58 -06:00
README.md Update README 2026-09-04 23:34:15 -06:00

ShapeDrawer9001

High tech program that takes a file containing a list of shapes and outputs a bitmap rendering.

The original proposal is located in proposal/

Notable deviations from proposal

  • FileWriter
    • write() ended up containing a lot of duplicate code between the different file formats, so I decided to write a single write() function that handles everything except writing the pixel data, and then instead defined a writePixel() abstract function which each filetype overrides with it's own definition.
  • Added a blendColor() function to increase readability of lines with setPixel()
  • ShapesList
    • The standard forward_list implementation required a custom tail iterator, which required rebuilding to ensure that it was still valid. This was done by traversing the list, which is slow and bad, especially since it was already in a for loop during parsing. This makes parsing files O(n) instead of O(n^2).

Notable deviations from style guidelines

using namespace std;

This works fine for smaller programs, but in larger projects this tends to lead to namespace collisions. It also self-documents where a function came from when you use "std::func".

Single class per file

In this project, I put classes into header files by hierarchy. The three shape classes are fairly small and always used together, so it didn't make sense to split them up.

FileWriter was done for similar reasons.

Compilation

Requirements:

  • An OS that can execute ELF files
  • A compiler with C++17 support and a standard library implementing:
    • string
    • cstdint
    • fstream
    • sstream
    • forward_list
    • iostream
    • cmath
    • algorithm

make will generate bin/shapedrawer9001

Usage

shapedrawer9001 file1 [file2... ] output

If your computer does not have an image viewer which can view PPM/PGM files directly, ImageMagick convert on Linux can convert PPM/PGM files to PNG (or many other formats).

magick convert $INPUT.ppm $OUTPUT.png