User Tools

Site Tools


notes:cprog:fall2023:projects:gtf0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:cprog:fall2023:projects:gtf0 [2023/08/27 12:09] – external edit 127.0.0.1notes:cprog:fall2023:projects:gtf0 [2023/09/07 01:47] (current) – [DRAWING A LINE] xcroft
Line 2: Line 2:
  
 =====GRABIT===== =====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===== =====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===== =====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
 +<blockquote> nano gtf0.c </blockquote>
 +
 +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===== =====RUN THE PROGRAM=====
  
 +First, compile the program using the following command:
 +
 +<blockquote>gcc -Wall --std=genu18 -o gtf0 gtf0.c -lgd</blockquote>
 +
 +Once it's compiled, there is now an executable called gtf0. Do the following, <blockquote> ./gtf0 </blockquote> 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===== =====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===== =====LIBGD FUNCTIONALITY=====
  
 ====MIXING A COLOR==== ====MIXING A COLOR====
  
-====DRAWING A LINE====+https://www.quackit.com/css/color/charts/web_safe_color_chart.cfm
  
-====DRAWING A RECTANGLE====+Find a color you like. In this case, we'll be using #33FFCC and will be calling it cyan.
  
 +Declare cyan as a variable:
 +
 +<blockquote> int             cyan             =0; </blockquote>
 +
 +Then we can allocate the value for the variable.
 +
 +<blockquote> cyan            =gdImageColorAllocate (image, 0x33, 0xFF, 0xCC);
 +</blockquote>
 +
 +
 +====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==== ====FILLING AN ENCLOSED SPACE====
 +Do  gdImageFill (image, x, y, color);
  
 ====DRAWING A FILLED RECTANGLE==== ====DRAWING A FILLED RECTANGLE====
  
 +The command to draw a filled in rectangle is as follows,
 +
 +<blockquote> gdImageFilledRectangle (image, x, y, x2, y2, color); </blockquote>
 ====DRAWING A CIRCLE==== ====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==== ====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.
notes/cprog/fall2023/projects/gtf0.1693138148.txt.gz · Last modified: 2023/08/27 12:09 by 127.0.0.1