User Tools

Site Tools


notes:cprog:spring2024: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:spring2024:projects:gtf0 [2024/02/08 03:17] – [FILLING AN ENCLOSED SPACE] basic syntax and explanation hcopp1notes:cprog:spring2024:projects:gtf0 [2024/02/08 04:20] (current) – [VIEW THE IMAGE] hcopp1
Line 8: Line 8:
 =====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:
 +<code>make debug</code>
 +Issue the command ''ls -l'' and if there is a green "gft0" file, everything worked :) {for now}
 +
 +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 ~/public_html/
 +   
 +<code>username@lab46:~/src/spring2024/gtf0$ cp ./gft0.png ~/public_html</code>
 +     
 +2. Change current directory to ~/public_html 
 +   
 +<code>cd ~/public_html</code>
 +     
 +3. Change permissions to be able to be read by all
 +   
 +<code>chmod +r gtf0.png</code>
 +     
 +4.view image from web browser
 +   
 +<code>https://lab46.g7n.org/~username/gtf0.png</code>
 =====LIBGD FUNCTIONALITY===== =====LIBGD FUNCTIONALITY=====
  
Line 19: Line 50:
 <code>                         image  red   green blue <code>                         image  red   green blue
 black = gdColorAllocate (image, 0x00, 0x00, 0x00);</code> black = gdColorAllocate (image, 0x00, 0x00, 0x00);</code>
 +
 +''red  green  blue'' sections are in hexcode so the most intense value is ''0xFF'' and the least being ''0x00'' 
 +
 +so if <color #ed1c24>red</color> and <color #00a2e8>blue</color> = ''0xFF'' 
 +
 +and <color #22b14c>green</color> = ''0x00'' 
 +
 +you will get <color #c8bfe7>purple</color> 
 +
 +
 ====DRAWING A LINE====  ====DRAWING A LINE==== 
  
Line 40: Line 81:
  
 <code>gdImageFilledRectangle (image, topleftX, topleftY, bottomrightX, bottomrightY, color)</code> <code>gdImageFilledRectangle (image, topleftX, topleftY, bottomrightX, bottomrightY, color)</code>
 +
 +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:
 +<code>gdImageArc (image, centerX, centerY, diameterWidth, diameterHeight, start°, end°, colorofLine);</code>
 +
 +Circle Ex:
 +<code>gdImageArc (image 150, 300, 100, 100, 0, 360, black);</code>
 ====DRAWING AN ELLIPSE==== ====DRAWING AN ELLIPSE====
  
 +Syntax for an Ellipse
 +<code>gdImageEllipse ( X1, Y2, width, height, colorofLine);</code>
 +(could also be used for a circle)
 +
 +Syntax for an Filled Ellipse
 +<code>gdImageFilledEllipse ( X1, Y2, width, height, colorofFill);</code>
notes/cprog/spring2024/projects/gtf0.1707362273.txt.gz · Last modified: 2024/02/08 03:17 by hcopp1