Corning Community College
CSCS1320 C/C++ Programming
To apply our existing knowledge of programming constructs in the application of a specific end result: a program that utilizes an image processing library to produce an image of a circle, constructed of squares.
In addition to the new skills required on previous projects, to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:
We've spent our time so far this semester covering the basic concepts of programming, in C. Variables, selection statements, iteration, functions, structs, etc.
Now that we've gotten through all of them, it is time to start applying those concepts so that deeper and further familiarity can be gained. This project is one such attempt at that.
We all know what a circle is, and in various math classes we've even explored various methods for doing things with circles (they have a radius, a circumference, a diameter), but how would we enable the computer to draw a circle?
One piece of that, obviously, is the math.
Another piece is the programmatic piece. A circle implies something visual. On the computer that means an image.
So: we are going to use the gd image processing library to aid us in generating the image.
Your task is to write a program that generates an image (PNG file), that is placed in your lab46 webspace for viewing, that does the following:
Now, gd has functions for drawing circles. You are NOT to use them for this project. As I said, this is a circle of squares. As such, you will be making use of the gdImageFilledRectangle() function.
I rigged up a skeleton file in a grabit project to kickstart your efforts.
To “grab” it:
lab46:~/src/cprog$ grabit cprog cos0 make: Entering directory '/var/public/SEMESTER/cprog/cos0' ‘/var/public/SEMESTER/cprog/cos0/Makefile’ -> ‘/home/USERNAME/src/cprog/cos0/Makefile’ ‘/var/public/SEMESTER/cprog/cos0/cos0.c’ -> ‘/home/USERNAME/src/cprog/cos0/cos0.c’ make: Leaving directory '/var/public/SEMESTER/cprog/cos0' lab46:~/src/cprog$ cd cos0 lab46:~/src/cprog/cos0$ ls Makefile cos0.c lab46:~/src/cprog/cos0$
And, of course, your basic compile and clean-up operations:
Just another “nice thing” we deserve.
NOTE: You do NOT want to do this on a populated cos0 project directory– it will overwrite files. Only do this on an empty directory.
Depending on your computing setup, choose the most practical means of viewing your program's image output:
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 cos0.png image in your ~/src/desig/cos0/ directory.
Rinse and repeat as you go through revisions.
You don't have a monitor, so you are logging into your pi remotely (doable, and good intra-system practice)
We start by running a successfully-compiled cos0:
yourpi:~/src/desig/cos0$ ./cos0
… which will produce an image (cos0.png); You want to put this in your web space (with the proper permissions set), so you can view it in a web browser:
yourpi:~/src/desig/cos0$ scp cos0.png yourusername@lab46.g7n.org:public_html/
Note that you will be prompted for your lab46 password.
Then over on lab46, run this:
lab46:~$ chmod 0644 ~/public_html/cos0.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.
To successfully complete this project, the following criteria must be met:
To submit this program to me using the submit tool, run the following command at your lab46 prompt:
$ submit cprog cos0 cos0.c Submitting cprog project "cos0": -> cos0.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:
91:cos0:final tally of results (91/91) *:cos0:no negative compiler messages for program [13/13] *:cos0:post generated image to #desig [13/13] *:cos0:grabit on the code on lab46 by Sunday before deadline [13/13] *:cos0:cos0.c code adequately modified per project requirements [39/39] *:cos0:updated code is pushed to lab46 repository [13/13]
Additionally: