Table of Contents

Corning Community College

ENGR1050 C for Engineers

PROJECT: Graphics To Figure-out (GTF0)

OBJECTIVE

As we start our journey into programming, despite not yet having learned much, let us see how our observational and pattern-matching and problem solving skills can still yield productive changes toward the solution of a task.

TASK

You are to modify provided code, once functionality and operations of it are understood, to produce, as image output, a scene containing the following characteristics:

EDIT

You will want to go here to edit and fill in the various sections of the document:

GTF0

GRABIT

Just typing in grabit will send you back an error, saying you need a designation and project. It it will then show you a list of designations. You will want c4eng. If you just type in “grabit c4eng” into the prompt, it will still pop back an error, but it will give you a list of projects to pick from. For this specific project, you will want to type in “grabit c4eng gtf0” into the prompt.

NOTE: Make sure you're in the correct directory before you move the files! In this case, you want to be in your repository.

REPOSITORY STEPS

No src? Type into the prompt “fixrepo”. This clones the repositories Matt set up for us this semester. Follow the instructs as they show up on the screen. No need to set up a passkey.

Now, a new directory will appear when you use the ls command, called src. Type in “cd src” to get into this new directory. If you use the command “ls” again, you will see two directories, fall2024 and unix. You will want to cd into fall2024, this is where your semester repository is stored. If you don’t have c4eng as an available directory when you use the ls command, type in “mkdir c4eng“ (mkdir stands for make directory). The cd into the new c4eng. You will keep all of projects here. Nothing is here yet, so you will have to use the grabit command.

BUILD THE CODE

In order to build the code you first need to follow the steps above labeled “grabit” in order to get the gtf0 project file into your repository. After retreiving the gtf0 project file, you should enter the file using the command “cd gtf0”. This command will change where you are in your repository to the gtf0 project file. Then if you use the command “ls”, you will see that there are two files inside of the gtf0 directory. The files are “Makefile” and “gtf0.c”. The “gtf0.c” file is the file that contains the code in which you will be editing and changing in order to complete the project. In order to access the file and to edit the code you use the command “vim gtf0.c” or “nano gtf0.c” depending on which text editor you would like to edit inside of.

RUN THE PROGRAM

In order to run the program we will run the command “make” while inside of the gtf0 directory. After using the “make” command use ”./gtf0“ and this command will create a png file for the gtf0.c code inside of the gtf0.c file which can then be moved and viewed.

VIEW THE IMAGE

in Lab46, ensure you are in the directory where you executed ” gtf0 “. Run the ” ls “ command, you should see ” gtf0.png “ in your current directory

Run the following move command ” mv gtf0.png ~/public_html “ to move the image file to a viewable website

Run the ” ls “ command, if ” gtf0.png “ is no longer in your current directory then it was successfully moved

In a web browser, navigate to the following URLhttps://lab46.g7n.org/~USERNAME/gtf0.png

replacing ” USERNAME “ with your lab46 username, make sure to keep the tilde ”~“

Your output image should be displayed

If you get a ” 404 not found “ error, run the following command in lab46 ” cd ~/public_html

Then run the command ” ls “, if the following ” gtf0.png “ is not listed as a file contained within the directory it was not successfully moved, review the first step

LIBGD FUNCTIONALITY

MIXING A COLOR
DRAWING A LINE

Use Function “gdImageLine (image, starting-X, starting-Y, terminating-X, terminating-Y, color);”

DRAWING A RECTANGLE

Use function “gdImageRectangle (image, top left-X, top left-Y, bottom right-X, bottom right-Y, outline color);”

FILLING AN ENCLOSED SPACE

Use code, “gdImageFill (image, x-coordinate, y-coordinate, color to fill);”

DRAWING A FILLED RECTANGLE

Use code, “gdImageFilledRectangle (image, x-coordinate, y-coordinate, final x-coordinate, final y-coordinate, color);”

DRAWING A CIRCLE

Use code, “gdImageArc (image, center x-coordinate, center y-coordinate, diameter x, diameter y, start angle, end angle, color of the outline);”

DRAWING AN ELLIPSE

Use code “gdImageArc (image, center x-coordinate, center y-coordinate, diameter x, diameter y, start angle, end angle, color);” (make sure the x and y diameters do not match - you WILL end up with a circle)

 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

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.

RUBRIC

I'll be evaluating the project based on the following criteria:

39:gtf0:final tally of results (39/39)
*:gtf0:modified code appropriately to accomplish task [13/13]
*:gtf0:commented code adequately to describe process [13/13]
*:gtf0:removed unused code [13/13]

Pertaining to the collaborative authoring of project documentation

Additionally