Imager
view release on metacpan or search on metacpan
lib/Imager/Draw.pod view on Meta::CPAN
$image->box(..., color => $colors[rand @colors]);
}
=head2 Fill Parameters
X<fill parameters>
All filled primitives, i.e. C<arc()>, C<box()>,
C<circle()>, C<polygon()> and the C<flood_fill()> method can take a
C<fill> parameter instead of a C<color> parameter which can either be
an Imager::Fill object, or a reference to a hash containing the
parameters used to create the fill, for example:
$image->box(..., fill=>{ hatch => 'check1x1' });
my $fillimage = Imager->new;
$fillimage->read(file=>$somefile) or die;
$image->flood_fill(..., fill=>{ image=>$fillimage });
Currently you can create opaque or transparent plain color fills,
hatched fills, image based fills and fountain fills. See
L<Imager::Fill> for more information.
=head2 Polygon Fill Modes
When filling a polygon that overlaps itself, or when filling several
polygons with polypolygon() that overlap each other, you can supply a
C<mode> parameter that controls how the overlap is resolved. This can
have one of two possible values:
=over
=item *
C<evenodd> - if areas overlap an odd number of times, they are filled,
and are otherwise unfilled. This is the default and the historical
Imager polygon fill mode.
=item *
C<nonzero> - areas that have an unbalanced clockwise and
anti-clockwise boundary are filled. This is the same as
C<WindingRule> for X and C<WINDING> for Win32 GDI.
=back
C<nonzero> allows polygons to overlap, either with itself, or with
another polygon in the same polypolygon() call, without producing
unfilled area in the overlap, and also allows areas to be cut out of
the area by specifying the points making up a cut-out in the opposite
order.
=head2 List of primitives
=over
=item line()
$img->line(color=>$green, x1=>10, x2=>100,
y1=>20, y2=>50, aa=>1, endp=>1 );
X<line method>
Draws a line from (x1,y1) to (x2,y2). The endpoint
(x2,y2) is drawn by default. If C<endp> of 0 is specified then the
endpoint will not be drawn. If C<aa> is set then the line will be
drawn anti-aliased. The C<antialias> parameter is still available for
backwards compatibility.
Parameters:
=over
=item *
C<x1>, C<y1> - starting point of the line. Required.
=item *
C<x2>, C<y2> - end point of the line. Required.
=item *
C<color> - the color of the line. See L</"Color Parameters">. Default:
black.
=item *
C<endp> - if zero the end point of the line is not drawn. Default: 1
- the end point is drawn. This is useful to set to 0 when drawing a
series of connected lines.
=item *
C<aa> - if true the line is drawn anti-aliased. Default: 0.
=back
=for stopwords
polyline polypolygon
=item polyline()
$img->polyline(points=>[[$x0,$y0],[$x1,$y1],[$x2,$y2]],color=>$red);
$img->polyline(x=>[$x0,$x1,$x2], y=>[$y0,$y1,$y2], aa=>1);
X<polyline method>
C<polyline> is used to draw multiple lines between a
series of points. The point set can either be specified as an
arrayref to an array of array references (where each such array
represents a point). The other way is to specify two array
references.
The C<antialias> parameter is still available for backwards compatibility.
=over
=item *
points - a reference to an array of references to arrays containing
the co-ordinates of the points in the line, for example:
my @points = ( [ 0, 0 ], [ 100, 0 ], [ 100, 100 ], [ 0, 100 ] );
$img->polyline(points => \@points);
=item *
( run in 1.155 second using v1.01-cache-2.11-cpan-524268b4103 )