User Tools

Site Tools


notes:c4eng:fall2023:projects:gtf0

This is an old revision of the document!


GTF0

GRABIT

Enter your c4eng directory by using the cd command like so:

cd src/fall2023/c4eng/

Now make a directory for the project gtf0 using the mkdir command:

mkdir gtf0

And use cd to enter it.

You can now use the grabit command to get the project files for gtf0:

grabit c4eng gtf0

You can use ls to check that the correct files are there. You should see 2 files, Makefile and gtf0.c.

REPOSITORY STEPS

BUILD THE CODE

RUN THE PROGRAM

VIEW THE IMAGE

LIBGD FUNCTIONALITY

MIXING A COLOR

We can add our own colors to be used in our PNG as well. The first step in doing so is to declare our color as a variable.

At the top of our file, right below int main(), we can see a section with some commented out text that reads “Declare variables”. In the actual code, we can already see some declared colors! For example, there's int white = 0;

So now we know how to declare a color for ourselves. Add another line, and try to maintain the same spacing for readability. You can name your color whatever you'd like, however there are some restrictions for naming variables in C. We should also maintain the same naming conventions that have already been used for readability.

For example, you can add int orange = 0;

Right now, the number you're assigning should just be 0. We will change this later using a number format that's more apt for color assignments.

DRAWING A LINE

DRAWING A RECTANGLE

FILLING AN ENCLOSED SPACE

DRAWING A FILLED RECTANGLE

DRAWING A CIRCLE

DRAWING AN ELLIPSE

notes/c4eng/fall2023/projects/gtf0.1693786506.txt.gz · Last modified: 2023/09/04 00:15 by mwinter4