haas:fall2020:cprog:projects:cos0
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:fall2020:cprog:projects:cos0 [2020/03/05 06:48] – external edit 127.0.0.1 | haas:fall2020:cprog:projects:cos0 [2020/10/19 16:14] (current) – [Raspberry Pi command-line via SSH/MOSH] wedge | ||
---|---|---|---|
Line 53: | Line 53: | ||
Now, gd has functions for drawing circles. You are **NOT** to use them for this project. As I said, this is a circle //of squares//. As such, you will be making use of the **gdImageFilledRectangle()** function. | Now, gd has functions for drawing circles. You are **NOT** to use them for this project. As I said, this is a circle //of squares//. As such, you will be making use of the **gdImageFilledRectangle()** function. | ||
- | ====getting started==== | ||
- | You may make use of the following skeleton program to assist you in doing this project. | ||
- | |||
- | Note that this code is not in conformance with project specifications, | ||
- | |||
- | <code c> | ||
- | /* | ||
- | * cos0.c | ||
- | | ||
- | * | ||
- | * To compile: type ' | ||
- | | ||
- | * To execute: ./cos0 ARGS | ||
- | * | ||
- | * Documentation: | ||
- | | ||
- | */ | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | |||
- | // color values | ||
- | // | ||
- | #define BLACK 0 | ||
- | #define BLUE 1 | ||
- | #define GREEN 2 | ||
- | #define RED 3 | ||
- | #define WHITE 4 | ||
- | |||
- | int main(int argc, char **argv) | ||
- | { | ||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Declare variables | ||
- | // | ||
- | char | ||
- | FILE | ||
- | gdImagePtr | ||
- | unsigned int color[5]; | ||
- | unsigned short int wide, high; // image attributes | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Check arguments | ||
- | // | ||
- | if (argc == 2) | ||
- | { | ||
- | outfile | ||
- | fprintf(stdout, | ||
- | } | ||
- | else | ||
- | { | ||
- | outfile | ||
- | sprintf(outfile, | ||
- | } | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // image dimensions | ||
- | // | ||
- | wide = 600; | ||
- | high = 800; | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Create new image of specified wide-ness and high-ness | ||
- | // | ||
- | img = gdImageCreate(wide, | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Some GD color definitions | ||
- | // | ||
- | color[BLACK] | ||
- | color[BLUE] | ||
- | color[GREEN] | ||
- | color[RED] | ||
- | color[WHITE] | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Paint the background black | ||
- | // | ||
- | gdImageFilledRectangle(img, | ||
- | |||
- | / | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Open the file | ||
- | // | ||
- | out = fopen(outfile, | ||
- | if(out | ||
- | { | ||
- | fprintf(stderr, | ||
- | exit(1); | ||
- | } | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Set sane file permissions on image file | ||
- | // | ||
- | chmod (outfile, 0644); | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Send image to file | ||
- | // | ||
- | gdImagePngEx(img, | ||
- | |||
- | ////////////////////////////////////////////////////////////////// | ||
- | // | ||
- | // Close things up | ||
- | // | ||
- | fclose(out); | ||
- | gdImageDestroy(img); | ||
- | |||
- | return(0); | ||
- | } | ||
- | </ | ||
- | |||
- | =====How to view your image===== | ||
- | When you have a functioning project and want to view the images generated, you need to make sure they are deployed into your **public_html/ | ||
- | |||
- | To view your image in a web browser, simply point it at the following URL: | ||
- | |||
- | * < | ||
- | |||
- | ... where " | ||
- | |||
- | Note that the tilde just prior to your username in the URL is critical and necessary. | ||
=====Grabit Integration===== | =====Grabit Integration===== | ||
Line 203: | Line 66: | ||
make: Leaving directory '/ | make: Leaving directory '/ | ||
lab46: | lab46: | ||
- | lab46: | + | lab46: |
Makefile | Makefile | ||
- | lab46: | + | lab46: |
</ | </ | ||
Line 218: | Line 81: | ||
NOTE: You do NOT want to do this on a populated **cos0** project directory-- it will overwrite files. Only do this on an empty directory. | NOTE: You do NOT want to do this on a populated **cos0** project directory-- it will overwrite files. Only do this on an empty directory. | ||
+ | =====How to view the picture===== | ||
+ | Depending on your computing setup, choose the most practical means of viewing your program' | ||
+ | |||
+ | ====Raspberry Pi desktop==== | ||
+ | You've got a monitor and keyboard hooked up to your pi that you are using (preferred method for class). | ||
+ | |||
+ | Open a file browser, web browser, or image viewer and navigate to/open up your **cos0.png** image in your **~/ | ||
+ | |||
+ | Rinse and repeat as you go through revisions. | ||
+ | |||
+ | ====Raspberry Pi command-line via SSH/ | ||
+ | You don't have a monitor, so you are logging into your pi remotely (doable, and good intra-system practice) | ||
+ | |||
+ | We start by running a successfully-compiled **cos0**: | ||
+ | |||
+ | <cli> | ||
+ | yourpi: | ||
+ | </ | ||
+ | |||
+ | ... which will produce an image (**cos0.png**); | ||
+ | |||
+ | <cli> | ||
+ | yourpi: | ||
+ | </ | ||
+ | |||
+ | Note that you will be prompted for your lab46 password. | ||
+ | |||
+ | Then over on lab46, run this: | ||
+ | |||
+ | <cli> | ||
+ | lab46:~$ chmod 0644 ~/ | ||
+ | </ | ||
+ | |||
+ | Then, point a web browser at the following URL: | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | NOTE: sometimes the web browser caches previous results, you may have to refresh a few times on revisions to get changes to manifest. | ||
=====Submission===== | =====Submission===== | ||
To successfully complete this project, the following criteria must be met: | To successfully complete this project, the following criteria must be met: | ||
Line 246: | Line 147: | ||
< | < | ||
- | 78:cos0:final tally of results (78/78) | + | 91:cos0:final tally of results (91/91) |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
*:cos0:no negative compiler messages for program [13/13] | *:cos0:no negative compiler messages for program [13/13] | ||
- | *:cos0:code is pushed to lab46 repository [13/13] | + | *:cos0:post generated image to #desig [13/13] |
+ | *: | ||
+ | *: | ||
+ | *: | ||
</ | </ | ||
haas/fall2020/cprog/projects/cos0.1583408924.txt.gz · Last modified: 2020/03/05 06:48 by 127.0.0.1