Subject: | GD::Simple cannot draw a filled arc in white |
Perl = v5.8.7 built for i586-linux-thread-multi,
O/S = Linux 2.6.13-15.10-default #1 Fri May 12 16:27:12 UTC 2006 i686
athlon i386 GNU/Linux
Latest CPAN d/l of GD & GD::Simple
per ticket 34281
using $img->bgcolor('white'); and $img->fgcolor('white') only ever
draws unfilled arcs. See code and example output
Subject: | arc.pl |
use GD::Simple;
$img = GD::Simple->new(500,500);
# Beware, the documentation for GD::Simple->arc is so inaccurate,
# you can't even say it's wrong. I don't know if it describes an old,
# obsolete and long-forgotten version of the library - or it was
# written for something else completely.
# First of all, it takes 5 arguments, max. Not 6 as described
# in perldoc GD::Simple, viz.
# $imgârc($cx,$cy,$width,$height,$start,$end [,$style])
# This method draws filled and unfilled arcs. See GD for a description of the arguâ
# ments. To draw a solid arc (such as a pie wedge) set bgcolor equal to fgcolor. To
# draw an unfilled arc, set bgcolor to undef.
# Here's the right version:
# as arc(a1, a2, a3, a4, a5)
# a1 and a2 are the size of the arc: a1 is it's height
# a2 is the width
#
# a3 and a4 are the star and end position of the arc.
# a3 describes the angle to start "arcing", with 0 degrees
# being at 03:00.
# a4 is the end angle, running in a clockwise direction
#
# You must specify the origin of the arc with a moveTo before
# you start plotting.
#
# You can specify a fifth, optional, argument which determines
# if the arc is filled (default) or not (gdNoFill) and has
# edges by setting gdEdged
# gdArc appears to draw an arc around the outside of an unfilled arc
# and gdChord joins the ends and optionally fills the closed segment.
# Here are some examples, to illustrate the above.
###############################################################################
$img->bgcolor('blue');
$img->fgcolor('blue');
$img->moveTo(450,175);
$img->arc(50, 50, 60, 10);
$img->moveTo(450,225);
$img->arc(50, 50, 90, 0);
$img->moveTo(450,275);
$img->arc(50, 50, 180, 0);
$img->moveTo(450,325);
$img->arc(50, 50, 180, 0, gdNoFill|gdEdged),;
$img->moveTo(450,375);
$img->arc(50, 50, 0, 270);
$img->moveTo(450,425);
$img->arc(50, 50, 270, 0);
$img->moveTo(450,475);
$img->arc(50, 50, 90, 10, gdArc|gdNoFill|gdEdged);
$img->bgcolor('red');
$img->fgcolor('red');
$img->moveTo(200,400);
$img->arc(50, 50, 50, 100);
$img->bgcolor('brown');
$img->fgcolor('brown');
$img->moveTo(200,80);
$img->arc(90, 135, 100, 50);
$img->bgcolor('brown');
$img->fgcolor('brown');
$img->moveTo(350,80);
$img->arc(90, 135, 20, 50);
$img->bgcolor('black');
$img->fgcolor('black');
$img->rectangle(100, 200, 180, 380);
$img->bgcolor('white');
$img->fgcolor('white');
$img->moveTo(140,240);
$img->arc(60, 60, 90, 270); # can't draw filled arcs in white
$img->bgcolor('lightgrey'); # have to sunstitute light grey N.B. grey, not gray.
$img->fgcolor('lightgrey');
$img->moveTo(140,340);
$img->arc(60, 60, 90, 270);
print $img->png;