Corning Community College
CSCS1730 UNIX/Linux Fundamentals
As we are still early in our journey, 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.
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:
You will want to go here to edit and fill in the various sections of the document:
grabit unix gtf0
Use the “hg add” command after you grab the project to add it to the repository.
Then use the “hg commit -m ”(message here)“” command to let yourself know any changes you made before adding it to your repository.
Then use the “hg push” command to finalize adding the file with the commit message.
On a different system, you can use “hg pull” and “hg update” to update your changes on different systems, allowing you to save and load your work on lab 46 or on your personal system.
To use the gtf0.c program you do not need to compile it. Once you have edited and changed the code with a text editor and saved it, you can run ./gtf0.c to run it.
Afterwards you can use the mv command to move it to public_html.
It can be helpful to have a second terminal and a window showing your gtf0.png picture so that you can see your changes more quickly. Have your open .c file on one terminal, use the other terminal to run your .c file and to move the resulting .png file to public_html, and the window showing your picture so you can refresh it to see changes.
To view your picture you go into your file explorer where you put your Unix file and find the “gtf0.png” and then click on it to view your image.
You can also view it in a web browser at https://lab46.g7n.org/~username/gtf0.png
Documentation: https://libgd.github.io/manuals/2.3.0/files/preamble-txt.html
API: https://libgd.github.io/manuals/2.3.0/index/Functions.html
You can make a color by declaring a new variable int colorName = 0; and then defining it like colorName = gdImageColor (image, 0x??, 0x??, 0x??);. The 0x?? is the amount of red, green, and blue (respectively) that is in your color. The 0x?? format is hexidecimal so the highest amount of each color would be 0xFF and the lowest would be 0x00.
A line can be drawn with the command gdImageLine (image, x, y, x2, y2, color);. x and y are the starting x and y positions, x2 and y2 are the ending x and y positions and color is which color you want it to be.
gdImageRectangle (image, x, y, x2, y2, color);
gdImageFill (image, x, y, color);
gdImageFilledRectangle (image, x, y, x2, y2, color);
gdImageArc (image, center x, center y, width, height, 360, 360, color);
In order to make a perfect circle, you should ensure that the width and height are the same.
An ellipse is much like a circle, but the main difference is that where a circle has an equal diameter for both the x and y axis, an ellipse will have different diameters. To draw, use the same function used for drawing circles gdImageArc (image, center x, center y, x diameter, y diameter, angle start, angle end, color). Understand that when the machine is drawing the arc, the line of the arc itself is half the distance of the diameter from the center. In other words, the diameter inputs refer to the measurement from end to end of the arc horizontally and vertically once fully drawn. An easy way to produce an ellipse is to double the integer of just one diameter input. This will stretch it out in the direction you choose in the function.
To be successful in this project, the following criteria (or their equivalent) must be met:
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.
I'll be evaluating the project based on the following criteria:
26:gtf0:final tally of results (26/26) *:gtf0:modified code appropriately to accomplish task [16/16] *:gtf0:commented code adequately to describe process [8/8] *:gtf0:removed unused code [2/2]