Name

arc( ) — draw an arc, ellipse, or circle

Synopsis

GD::Image::arc(x, y, width, height, start, end, colorindex)

The arc( ) method allows you to draw arcs, circles, and ellipses on an image, centered at the coordinate given by x and y. The height parameter indicates the maximum diameter of the on the y axis and the width parameter is the maximum diameter on the x axis. For a circle, the height and width would both be equal to the diameter of the circle; you can vary either value to produce ellipses of various shapes. The start and end parameters are the starting and ending angles (in degrees) that the arc should sweep through. These angles are measured from the x axis and increase in the clockwise direction, with degrees at 3 o’clock, 90 degrees at 6 o’clock, and so on. To draw a circle centered at (100, 100) with a radius of 25 pixels, for example, you would use:

$image->arc(100, 100, 50, 50, 0, 360, $red);

To draw the right half of an ellipse, use:

$image->arc(100, 100, 100, 50, 270, 90, $red);

The colorindex parameter may be a color index or any of the special colors gdBrushed, gdStyled, or gdStyledBrushed.

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.