This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
notes:cprog:spring2024:projects:gtf0 [2024/01/22 13:22] – created - external edit 127.0.0.1 | notes:cprog:spring2024:projects:gtf0 [2024/02/08 04:20] (current) – [VIEW THE IMAGE] hcopp1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
=====GRABIT===== | =====GRABIT===== | ||
+ | The first step towards completing the project is to get the skeleton code and Makefile | ||
+ | Lab46 has a command you can run called grabit, it can be used by typing the command, followed by the course designation, | ||
+ | in this case it would be | ||
+ | < | ||
=====REPOSITORY STEPS===== | =====REPOSITORY STEPS===== | ||
=====BUILD THE CODE===== | =====BUILD THE CODE===== | ||
+ | |||
+ | Edit the provided skeletal code from the grabit using a txt editor like nano. edit this code to fit the criteria for the project | ||
+ | |||
+ | | ||
+ | |||
+ | |||
=====RUN THE PROGRAM===== | =====RUN THE PROGRAM===== | ||
+ | |||
+ | To be able to run the gtf0.c file use the following command in the grabit file: | ||
+ | < | ||
+ | Issue the command '' | ||
+ | |||
+ | If you execute this command it should produce a .png image | ||
=====VIEW THE IMAGE===== | =====VIEW THE IMAGE===== | ||
+ | |||
+ | The image can either be viewed, if on a Pi, from the GUI file explorer | ||
+ | |||
+ | Or if in lab46: | ||
+ | 1. Copy the file to ~/ | ||
+ | |||
+ | < | ||
+ | |||
+ | 2. Change current directory to ~/ | ||
+ | |||
+ | < | ||
+ | |||
+ | 3. Change permissions to be able to be read by all | ||
+ | |||
+ | < | ||
+ | |||
+ | 4.view image from web browser | ||
+ | |||
+ | < | ||
=====LIBGD FUNCTIONALITY===== | =====LIBGD FUNCTIONALITY===== | ||
====MIXING A COLOR==== | ====MIXING A COLOR==== | ||
+ | You can make custom colors in C with commands from the libgd library | ||
+ | so do this specify the integer variable that will have the color assigned to it | ||
+ | < | ||
+ | then using the gdImageColorAllocate command, specify the intensity of each color, red green and blue, and reassign the output to the color | ||
+ | < | ||
+ | black = gdColorAllocate (image, 0x00, 0x00, 0x00);</ | ||
- | ====DRAWING A LINE==== | + | '' |
+ | |||
+ | so if <color # | ||
+ | |||
+ | and <color # | ||
+ | |||
+ | you will get <color # | ||
+ | |||
+ | |||
+ | ====DRAWING A LINE==== | ||
+ | |||
+ | Syntax for drawing a graphics line | ||
+ | |||
+ | < | ||
====DRAWING A RECTANGLE==== | ====DRAWING A RECTANGLE==== | ||
+ | |||
+ | Syntax for drawing a graphics line | ||
+ | |||
+ | < | ||
====FILLING AN ENCLOSED SPACE==== | ====FILLING AN ENCLOSED SPACE==== | ||
+ | Basically the Fill bucket from any drawing software. | ||
+ | You specify where the coordinates of the fill is (another way of thinking is that the coordinates is specifying where the " | ||
+ | |||
+ | < | ||
====DRAWING A FILLED RECTANGLE==== | ====DRAWING A FILLED RECTANGLE==== | ||
+ | |||
+ | Syntax for drawing a graphics line | ||
+ | |||
+ | < | ||
+ | |||
+ | This will draw a solid rectangle of color | ||
====DRAWING A CIRCLE==== | ====DRAWING A CIRCLE==== | ||
+ | |||
+ | Syntax for a circle uses an arc command but the start angle is 0° and the end is 360° | ||
+ | (also the diameters are equal) | ||
+ | |||
+ | Arc syntax: | ||
+ | < | ||
+ | |||
+ | Circle Ex: | ||
+ | < | ||
====DRAWING AN ELLIPSE==== | ====DRAWING AN ELLIPSE==== | ||
+ | Syntax for an Ellipse | ||
+ | < | ||
+ | (could also be used for a circle) | ||
+ | |||
+ | Syntax for an Filled Ellipse | ||
+ | < |