The shadowgd class lets you draw the basic shapes in the GD graphics
module-- rectangle, polygon, ellipse and arc -- with a drop shadow.
The user can set the drop shadow's size, color and direction, as well
as specify whether an outline (and it's color) should be drawn around
The drop shadows are drawn using two shades of color. For a normal drop
shadow effect you would use two shades, one light and one dark, of the
same color. If you just want a solid drop shadow, you can assign the
same shade to both shadow color parameters or, for something entirely
different, use two different colors.
To use the shadowgd class, you must first include or require the file
shadowgdclass.php in your script, like
After creating a gd image with one of the standard ImageCreate
functions, you create a new instance of the shadowgd class, passing it
the handle of the image you created, such as
$grfx = new shadowgd($image);
When the shadowgd class is created, it initializes the drop shadow
parameters and the outline color to default values. You can draw
drop-shadow shapes with no further set-up or call the appropriate
functions to change these values at any time.
Using shadowgd class
The function calls in shadowgd class to draw drop-shadow shapes are
similar to the corresponding standard gd functions. One main difference
is that for all the functions the coordinates for the shape should be in
an array. For most of the standard gd functions the coordinates are
supplied as individual values. All the shadowgd functions are listed
below. For the color arguments, you should allocate the desired colors
in your script and pass the color identifiers in the function calls.
See the shadowgdclass.php file for more information on the functions.
This is the constructor, used to create a shadowgd class
SetShadow ($size, $direction, $lt_shadow, $drk_shadow)
This function is used to set the drop shadow parameters - size,
direction, and color. The direction is specified as:
This function is used to set the color of the outline if one is drawn
DrawShadowPolygon ($polygon_outline, $polygon_color, $show_outline = true)
This function draws a filled polygon in the specified colot with
a drop shadow
DrawShadowRectangle ($rect_coords, $rect_color, $show_outline = true)
This function draws a filled rectangle in the specified colot
with a drop shadow
DrawShadowEllipse ($ellipse_center, $ellipse_width, $ellipse_height,
$ellipse_color, $show_outline = true)
This function draws a filled ellipse in the specified colot with
a drop shadow
DrawShadowArc ($arc_center, $arc_width, $arc_height, $arc_start, $arc_end,
$arc_color, $show_outline = true)
This function draws a filled arc in the specified colot with a
drop shadow. It always draws a pie wedge type arc.
If you have any questions on shadowgd class, you can email me at
firstname.lastname@example.org and I'll try to answer them. I would also be
interested in hearing how you use shadowgd class, and welcome any
suggestions for improving it.
AJW Web Services