Skip Menu |
 

This queue is for tickets about the GD CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: perl [...] pete-lynch.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.16
  • 1.17
  • 1.18
  • 1.19
  • 1.20
  • 1.21
  • 1.22
  • 1.23
  • 1.24
  • 1.25
  • 1.26
  • 1.27
  • 1.28
  • 1.29
  • 1.30
  • 1.31
  • 1.32
  • 1.33
  • 1.35
  • 1.36
  • 1.37
  • 1.38
  • 1.39
  • 1.40
  • 1.41
  • 2.00
  • 2.01
  • 2.02
  • 2.04
  • 2.041
  • 2.05
  • 2.06
  • 2.07
  • 2.10
  • 2.11
  • 2.12
  • 2.15
  • 2.16
  • 2.17
  • 2.18
  • 2.19
  • 2.21
  • 2.22
  • 2.23
  • 2.25
  • 2.26
  • 2.27
  • 2.28
  • 2.29
  • 2.30
  • 2.31
  • 2.32
  • 2.34
  • 2.35
  • 2.39
  • 2.40
  • 2.41
  • 2.43
  • 2.44
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.
Subject: ptest.pl
Download ptest.pl
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;


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.