TechniqueUse the ImageArc() function to draw an arc to your image: <?php header("Content-type: image/gif"); $im = ImageCreate(100, 20); $white = ImageColorAllocate($im, 255, 255, 255); ImageColorTransparent($im, $white); $light_red = ImageColorAllocate($im, 233, 93, 20); ImageArc($im, 4, 5, 50, 40, 10, 180, $light_red); ImageGif($im); ImageDestroy($im); ?> CommentsThe ImageArc() function has the following syntax: int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col); This means it draws an arc to an image, im , with a start X position of cx and a start Y position of cy . The arc is of width w and height h , with a start angle of s and an end angle of e , all in the color col . The ImageArc() function can be used not only for drawing arcs but also for drawing circles and ellipses and filled circles and ellipses. The following is an example of drawing an ellipse using the ImageArc() function: <?php header("Content-type: image/gif"); $im = ImageCreate(500, 100); $white = ImageColorAllocate($im, 255, 255, 255); ImageColorTransparent($im, $white); $light_red = ImageColorAllocate($im, 233, 93, 20); ImageArc($im, 40, 50, 50, 40, 0, 360, $light_red); ImageGif($im); ImageDestroy($im); ?> The preceding code works because to have an ellipse, you need a 360-degree difference between the start position and the end position. Applying that knowledge, we can also draw a filled circle by using the ImageFillToBorder() function. (Note that this is a circle not an ellipse because the width and height parameters have the same value.) <?php header("Content-type: image/gif"); $im = ImageCreate(500, 100); $white = ImageColorAllocate($im, 255, 255, 255); ImageColorTransparent($im, $white); $light_red = ImageColorAllocate($im, 233, 93, 20); ImageArc($im, 40, 50, 50, 50, 0, 360, $light_red); ImageFillToBorder($im, 50, 40, $light_red, $light_red); ImageGif($im); ImageDestroy($im); ?> |