User Tools

Site Tools


haas:fall2023:cprog:projects:gtf0

Corning Community College

CSCS1320 C/C++ Programming

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:

  • confined within a square resolution of at least 1000×1000 pixels
  • contain at least:
    • 1 filled rectangle, no shorter than 32 pixels on any side
    • 1 unfilled rectangle, no shorter than 64 pixels on any side
    • 1 circle, diameter no smaller than 128 pixels
    • 1 ellipse
    • utilize at least 8 uniquely mixed colors
    • NOTE: background not a substitute for required filled rectangle above
  • annotate your image with your initials, ideally in some corner

EDIT

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

GTF0

GRABIT

You can do grabit DESIG PROJECT do grab the project. grabit cprog gtf0 is the command. Make sure to add it to your repository.

REPOSITORY STEPS

Once gtf0 has been grabbed: hg add gtf0 hg commit -m “MESSAGE HERE” to track what you have done hg push to push it into your repository

BUILD THE CODE

To start building the code, you have to edit the gtf0.c file. A terminal text editor is recommended.

For nano, the command is

nano gtf0.c

You will click ^x (Ctrl + X) to Exit the file, where it will then ask to save it under the same name.

RUN THE PROGRAM

First, compile the program using the following command:

gcc -Wall –std=genu18 -o gtf0 gtf0.c -lgd

Once it's compiled, there is now an executable called gtf0. Do the following,

./gtf0

There will now be a gtf0.png file.

Alternatively, if you want to use the “make” command to compile, you need to install the gd library. download the latest version, and extract the files using: tar -xf (file name).tar.gz Then cd into the file name, type ./configure to configure the archive Then type “make” The type “sudo make install” to finish installing the library. This isn't needed but knowing how to install packages and libraries may be useful in the future

VIEW THE IMAGE

One way to view the image is to go to the folder through file explorer where you put the image and view it from there.

Another way to view the image is to place it in your public web space using /bin/cp -f gtf0.png ~/public_html chmod 0644 ~/public_html/gtf0.png , then viewing in a web browser: https://lab46.g7n.org/~username/gtf0.png

LIBGD FUNCTIONALITY

MIXING A COLOR

https://www.quackit.com/css/color/charts/web_safe_color_chart.cfm

Find a color you like. In this case, we'll be using #33FFCC and will be calling it cyan.

Declare cyan as a variable:

int cyan =0;

Then we can allocate the value for the variable.

cyan =gdImageColorAllocate (image, 0x33, 0xFF, 0xCC);

DRAWING A LINE

Command for a Line is gdImageLine (image, x, y, x^2, y^2, color);

DRAWING A RECTANGLE

Command is gdImageRectangle (image, x, y, x^2, y^2, color);

FILLING AN ENCLOSED SPACE

Do gdImageFill (image, x, y, color);

DRAWING A FILLED RECTANGLE

The command to draw a filled in rectangle is as follows,

gdImageFilledRectangle (image, x, y, x2, y2, color);

DRAWING A CIRCLE

gdImageArc (image, center point X, center point Y, diameter X, diameter Y, Angle start, angle end, color);

Make sure the diameter X and Y are the same, as this makes a perfect circle

DRAWING AN ELLIPSE

gdImageArc (image, center point X, center point Y, diameter X, diameter Y, Angle start, angle end, color);

Make sure the diameter x and y are different integers, as this stretches the circle on the larger side making an ellipse.

 

SUBMISSION

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

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • All code must compile cleanly (no warnings or errors)
    • Compile with the -Wall and --std=gnu18 compiler flags
    • all requested functionality must conform to stated requirements (either on this document or in a comment banner in source code files themselves).
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no explicit calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool (make submit on lab46 will do this) by the deadline.

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:

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]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 256 bytes (absolute value of data content change))
      • near the class total content contribution average (a value of at least 1kiB)
      • no zero-sum commits (adding in one commit then later removing in its entirety for the sake of satisfying edit requirements)
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% 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 or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2023/cprog/projects/gtf0.txt · Last modified: 2023/08/27 08:11 by wedge