cmkl/fall-2025/sen-103/Labs/Lab3/Instructions.txt

120 lines
3.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

SEN-103 Programming Multi-Module Applications
Lab 3 Practice Assignment
Using External Libraries
Overview
In this lab exercise, you create a simple program that uses the capabilities in libgd, the GD graphics library.
Instructions
Preparation
Start by downloading and installing the GD library.
You will find the full source and information here:
https://github.com/libgd/libgd/releasesLinks to an external site.
If you are using Windows, you should download the source Zip file. (It may be easier if you do this lab using Linux.)
You will need to build (compile) the libraries on your own computer. To do this, read the README file and other documentation that comes in the release package. This is a big part of the exercise doing the necessary reading and detective work to get GD working on your computer.
I strongly recommend that you do this assignment in C. There is a Python wrapper for GD. You can use this if you want, but I warn you, there is almost no documentation.
If you want to use Python for your own program, you must download the Python wrapper code:
https://github.com/NOAA-ORR-ERD/py_gdLinks to an external site.
Note that you will still need the compiled C version of the library. However, it looks like the conda Python installer will handle a lot of this mess for you. See the information in the py_gd README file.
https://github.com/NOAA-ORR-ERD/py_gd/blob/master/README.mdLinks to an external site.
Assignment Instructions
For the lab assignment, write a program called gdSample.c or gd_sample.py that uses the GD library to do the following:
Create an empty, in-memory image that is 1000 pixels wide by 700 pixels wide.
Draw a filled orange circle, in the upper left part of the image.
Draw an unfilled blue rectangle with line width of 10 pixels, in the upper right part of the image.
Draw an unfilled red convex polygon with 7 vertices and a line width of 10 pixels, in the lower left part of the image.
Draw a filled purple square, in the lower right part of the image.
Draw a string with your full name in the middle of the image.
Write out the image as an JPG file.
To do this assignment, you will need to use the GD documentation for reference. The top level page for the online documentation is here:
https://libgd.github.io/manuals/2.3.3/files/preamble-txt.htmlLinks to an external site.
There is a set of links in the sidebar which take you to documentation for different topics.
I found the page below (accessible via Index/Functions) useful. It lists all the functions in GD in alphabetical order. If you click on a function name, you will see the arguments but no real explanation of what the function does. Fortunately, the functions are named in a systematic and pretty clear way.
https://libgd.github.io/manuals/2.3.3/index/Functions.htmlLinks to an external site.
The py_gd documentation seems to be pretty sparse or non-existent. There is one example here:
https://github.com/NOAA-ORR-ERD/py_gd/blob/master/docs/examples/mandelbrot.pyLinks to an external site.
You can also get some clues as to how to use the Python binding from the test scripts:
https://github.com/NOAA-ORR-ERD/py_gd/tree/master/py_gd/testLinks to an external site.
Note that even if you use Python, you will probably need to look at the functions in the C version to see what information you need to supply.
Write and test your gdSample.c or gd_sample.py program until it works correctly. Then upload your C or Python source file to Canvas + a screenshot showing your program work.