int gdImageColorAllocate( gdImagePtr image, int red, int green, int blue)
Sets the color index for the image using the RGB values red, green, blue and returns the index of the new color index. Then, you can use the returned value as a parameter to drawing functions. The first time you invoke this function, you are setting the background color for that image.
void gdImageSetThickness( gdImagePtr image, int thickness )
Sets the width of the lines used by drawing functions according to the thickness parameter.
void gdImageLine( gdImagePtr image, int x1, int y1, int x2, int y2, int color )
Draw a line from point x1, y1 to point x2, y2 using the color parameter.
Draw filled ellipses and circles
void gdImageFilledEllipse( gdImagePtr image, int cx, int cy, int width, int height, int color)
Draws an ellipse centered at point cx, cy, with the specified width and height in pixels. The ellipse is filled with the color parameter.
Draw filled rectangles and squares
void gdImageFilledRectangle( gdImagePtr image, int x1, int y1, int x2, int y2, int color )
Draws a solid rectangle from the upper left corner x1, y1 to the lower right corner x2, y2. The rectangle is filled with the color parameter.
Local variables declared inside functions may also have a static storage class.
duration: memory is allocated when the program starts and released when the program ends.
scope: variable is accessible only within the function – not outside of it.
The GD graphics library may also be used to draw individual chracters or text strings to the image.
The GD graphics library may also be used to create animated GIF images from a sequence of frame images.
Below is a program that draws one die based on a random number value.
Generate new designs of dice images. For example, try: