Bug in GD?

  • Thread starter 0liver 'ojo' Bedf0rd
  • Start date
0

0liver 'ojo' Bedf0rd

The following code:

#!/usr/bin/perl -w

use strict;
use GD;


my $im = new GD::Image(500,500);
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);
$im->arc(100,100,50,50,90,90,$blue);
$im->filledArc(200,200,50,50,90,90,$red,gdEdged|gdNoFill);
binmode STDOUT;
print $im->png;

produces full (360 °) circles in the output image, although I would
have guessed that no output at all (or a single pixel/line) is produced.
I still find it more sensible to assume that if start and end angle
are the same "minimal" output is created and not the "maximum" one.

So: am I wrong or is this a bug in GD?

Oliver
 
0

0liver 'ojo' Bedf0rd

Am Wed, 05 May 2010 22:59:15 +0100 schrieb Ben Morrow:

What do the docs say?

I didn't find anything relevant.
AFAICS, a full circle is more useful. There are many ways of producing a
single line; a full circle, however, can only be produced like that.

Well, no.

The "right" way to produce a full circle is of course to set the starting
angle to 0° and the end angle to 360°. (*)

Should produce a full circle IMVHO:
$im->arc(100,100,50,50,0,360,$blue);

Should produce "nothing" IMVHO
$im->arc(100,100,50,50,90,90,$blue);

Oliver

(*) I'm aware that 0°==360° from a mathematical point of view
 
S

smallpond

The following code:

#!/usr/bin/perl -w

use strict;
use GD;

my $im = new GD::Image(500,500);
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);      
my $red = $im->colorAllocate(255,0,0);      
my $blue = $im->colorAllocate(0,0,255);
$im->arc(100,100,50,50,90,90,$blue);
$im->filledArc(200,200,50,50,90,90,$red,gdEdged|gdNoFill);
binmode STDOUT;
print $im->png;

produces full (360 °) circles in the output image, although I would
have guessed that no output at all (or a single pixel/line) is produced.
I still find it more sensible to assume that if start and end angle
are the same "minimal" output is created and not the "maximum" one.

So: am I wrong or is this a bug in GD?

According to the docs for gdImageArc:
"e must be greater than s"

http://www.libgd.org/Drawing
 
0

0liver 'ojo' Bedf0rd

Am Thu, 06 May 2010 07:41:40 -0700 schrieb smallpond:

According to the docs for gdImageArc: "e must be greater than s"

http://www.libgd.org/Drawing

Ah, OK. I didn't find it in the perl doc.

The problem here is that although e may be greater than s,
GD uses only integer values and you don't get what you might
expect. I still think this is not the ideal behaviour.

Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top