Skip Menu | will be shut down on March 1st, 2021.

This queue is for tickets about the GD CPAN distribution.

Report information
The Basics
Id: 53538
Status: rejected
Priority: 0/
Queue: GD

Owner: Nobody in particular
Requestors: perl [...]

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)

Subject: GD::Simple->arc() start and end angles are incorrect
Download (untitled) / with headers
text/plain 793b
Version: there is none, there is only a single release in CPAN dated 2004 Problem: Calling $img->arc($width,$height,$start_angle,$end_angle); should draw an ellipse from $start_angle to $end_angle (angles in degrees). However, this only works properly if the width and height are the same - i.e. you are drawing part of a circle. If the shape is elliptical, the angles that the arc starts and end at are not the ones specified in the arguments. Thus: $img->arc(300,200,240,120); should draw an arc from 240 degrees to 120 degress. It doesn't. The start angle is more like 230 degrees and the end angle is approximately 130 degrees - measured from the "centre" of the ellipse, the point "moveTo'd" before the call to arc() See the included demo file for a graphic illustration of this mistake.
text/x-perl 1.6k
#!/usr/bin/perl use GD::Simple; $PI=3.141526; $RADIAN=360/(2*$PI); $img = GD::Simple->new(800,800); $img->fgcolor('gray'); $img->bgcolor(undef); for $i (100, 200, 300, 400, 500, 600, 700) { $img->moveTo(0,$i); $img->lineTo(799,$i); } for $i (100, 200, 300, 400, 500, 600, 700) { $img->moveTo($i,0); $img->lineTo($i,799); } $img->rectangle(0,0,799,799); # draw basic circle $img->moveTo(400,400); $img->ellipse(600,600); $img->fgcolor('black'); #label outside of circle for ($i=0; $i < 360;$i+=(360/24)) { $n = ($i+90) / $RADIAN; $x = 300 * sin $n; $y = 300 * cos $n; $img->moveTo(400+$x, 400-$y); $img->string($i); # N.B. the "string" changes the origin $img->moveTo(400+$x, 400-$y); $img->lineTo(400,400); # so we have to go back there } # plot an arc $img->moveTo(400,400); $img->fgcolor('green'); $img->arc(500,500,60,300); $img->moveTo(400,400); $img->fgcolor('green'); $img->arc(490,490,60,280); $img->moveTo(400,400); $img->fgcolor('green'); $img->arc(480,480,60,240); $img->moveTo(400,400); $img->fgcolor('green'); $img->arc(470,470,60,180); $img->moveTo(400,400); $img->fgcolor('blue'); $img->arc(300,200,240,120); $img->moveTo(400,400); $img->fgcolor('blue'); $img->arc(290,190,210,120); $img->moveTo(400,400); $img->fgcolor('blue'); $img->arc(280,180,180,120); $img->moveTo(400,400); $img->fgcolor('blue'); $img->arc(270,170,150,120); $img->moveTo(400,400); $img->fgcolor('red'); $img->arc(400,400,240,120); $img->moveTo(400,400); $img->fgcolor('red'); $img->arc(390,390,210,120); $img->moveTo(400,400); $img->fgcolor('red'); $img->arc(380,380,180,120); $img->moveTo(400,400); $img->fgcolor('red'); $img->arc(370,370,150,120); print $img->png;
Download (untitled) / with headers
text/plain 374b
arc just passes its arguments through to gdImageArc() It only checks if the center is needed and if the arc if filled or not. See Arithmetic errors are solely on libgd side. -- Reini Urban

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to