<http://lib.cnfolio.com/ENG421GraphicsAnimation>
Introduction to Algorithms and Programming

Graphics and animations using the GD library



Reference documentation about the GD graphics library and time and date functions:




Create an image file with a background color


int gdImageColorAllocate( gdImagePtr image, int red, int green, int blue)




Draw lines


void gdImageSetThickness( gdImagePtr image, int thickness )

void gdImageLine( gdImagePtr image, int x1, int y1, int x2, int y2, int color )




Draw filled ellipses and circles


void gdImageFilledEllipse( gdImagePtr image, int cx, int cy, int width, int height, int color)




Draw filled rectangles and squares


void gdImageFilledRectangle( gdImagePtr image, int x1, int y1, int x2, int y2, int color )




Static variables


Local variables declared inside functions may also have a static storage class.




Drawing text


The GD graphics library may also be used to draw individual chracters or text strings to the image.




Creating animation


The GD graphics library may also be used to create animated GIF images from a sequence of frame images.




Practice exercise


Below is a program that draws one die based on a random number value.

Generate new designs of dice images. For example, try: