Table of Contents
Corning Community College
CSCS1320 C/C++ Programming
Project: VISUALIZATION - FUN WITH FLAGS (fwf0)
Objective
To create a program that generates a representation of a flag of a certain level of design complexity.
Reading
Please be sure to familiarize yourself with the following content in “the C book”:
Background
For this project, you will be using a graphics design library to render an image of a flag.
While you are not restricted to officially recognized country flags, they do offer a great starting point:
If there is some fictional country, other state/county/canton, or organization symbol you would like to implement instead, you are welcome to (so long as they conform to the difficulty levels specified below).
Difficulties are defined as follows:
Easy
An easy-level flag has the following criteria:
- Solid colours, often in bands
- Examples: France, Mali, Belgium
Intermediate
Intermediate-level flags are classified as follows:
- At least three distinct colours used on the flag.
- More than one geometric shape utilized on the flag (ie not JUST rectangles/squares).
- Examples: Bahamas, Laos, Maldives, Niger
Medium
- Three or more colours
- Contains three different geometric shapes (oval(s), triangle(s), star(s), rectangle(s))
- Examples: Malaysia, Algeria, Antigua and Barbuda
Complex
- Increased level of detail above that of medium
- Creation utilizes loops
- Examples: USA, Croatia, Philippines
Program
It is your task to write a program that generates a flag image, in the current directory as your source code and binary, named and accessible as fwf0.png
The flag is to be an intermediate-level flag (although you might want to start with an easy-level flag to gain some practice with the library and things like coordinates); opting to do and submit something of higher difficulty may earn you some bonus points.
On your pi
Develop and test this program on your pi. Only when done, verify that it compiles on lab46.
To utilize the needed functionality for this project, you will need to ensure you have the following packages installed:
- build-essential (hopefully you took care of this in ntr0)
- libgd-dev
- libgd-tools
- libgd3
Specifications
Your program should:
- have valid, descriptive variable names of length no shorter than 4 symbols
- have consistent, well-defined indentation (no less than 4 spaces per level of indentation)
- all code within the same scope aligned to its indentation level
- have proximal comments explaining your rationale and what is going on, throughout your code
- perform the intended operation, outputting the correct/accurate information in indicated format
- at the end of your main() function, use a single return statement to conclude your code, return a 0 indicating successful operation
Grabbing project resources
I have prepared a grabit for resources related to this project. To obtain:
lab46:~/src/cprog$ grabit cprog fwf0 make: Entering directory '/var/public/SEMESTER/cprog/fwf0' '/var/public/SEMESTER/cprog/fwf0/Makefile' -> '/home/user/src/cprog/fwf0/Makefile' '/var/public/SEMESTER/cprog/fwf0/fwf0.c' -> '/home/user/src/cprog/fwf0/fwf0.c' make: Leaving directory '/var/public/SEMESTER/cprog/fwf0' lab46:~/src/cprog$
At which point you can change into the newly created and populated fwf0 directory.
Compiling
Since the grabit brought in a Makefile, you can compile your code simply by typing: make
Any compiler errors will go into a text file called errors
To do a full cleaning, run: make clean then make (or make debug)
If you'd like to see compiler messages as you compile, run: make debug
When done and ready to submit, on lab46: make submit
How to view the picture
Depending on your computing setup, choose the most practical means of viewing your program's image output:
Raspberry Pi desktop
You've got a monitor and keyboard hooked up to your pi that you are using (preferred method for class).
Open a file browser, web browser, or image viewer and navigate to/open up your fwf0.png image in your ~/src/desig/fwf0/ directory.
Rinse and repeat as you go through revisions.
Raspberry Pi command-line via SSH/MOSH
You don't have a monitor, so you are logging into your pi remotely (doable, and good intra-system practice)
Once your Makefile and fwf0.c file are added to your repository, commit and push.
On lab46, pull and update.
Compile:
lab46:~/src/desig/fwf0$ make
and run your program:
lab46:~/src/desig/fwf0$ ./fwf0
… which will produce an image (fwf0.png); You want to put this in your web space (with the proper permissions set), so you can view it in a web browser:
lab46:~/src/desig/fwf0$ mv fwf0.png ~/public_html/ lab46:~/src/desig/fwf0$ chmod 0644 ~/public_html/fwf0.png
Then, point a web browser at the following URL:
NOTE: sometimes the web browser caches previous results, you may have to refresh a few times on revisions to get changes to manifest.
Submission
To successfully complete this project, the following criteria must be met:
- Code must compile cleanly (no notes, warnings, nor errors)
- Output must be correct, and match the form given in the sample output above.
- Code must be nicely and consistently indented
- Code must be well commented
- Do NOT double space your code. Group like statements together.
- Output Formatting (including spacing) of program must conform to the provided output (see above).
- Track/version the source code in a repository
- Submit a copy of your source code to me using the submit tool.
To submit this program to me using the submit tool, run the following command at your lab46 prompt:
lab46:~/src/cprog/fwf0$ submit cprog fwf0 fwf0.c Submitting cprog project "fwf0": -> fwf0.c(OK) SUCCESSFULLY SUBMITTED
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
What I'll be looking for:
26:fwf0:final tally of results (26/26) *:fwf0:proper output formatting per specifications [13/13] *:fwf0:no negative compiler messages for program [7/7] *:fwf0:code is pushed to lab46 repository [6/6]
Additionally:
- Solutions not abiding by spirit of project will be subject to a 25% overall deduction
- Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
- Solutions not utilizing indentation to promote scope and clarity will be subject to a 25% overall deduction
- Solutions not organized and easy to read are subject to a 25% overall deduction