Imager
view release on metacpan or search on metacpan
lib/Imager/Fill.pm view on Meta::CPAN
=item *
C<check1x1>, C<check2x2>, C<check4x4> - checkerboards at various sizes
=item *
C<vline1>, C<vline2>, C<vline4> - 1, 2, or 4 vertical lines per cell
=item *
C<hline1>, C<hline2>, C<hline4> - 1, 2, or 4 horizontal lines per cell
=item *
C<slash1>, C<slash2> - 1 or 2 / lines per cell.
=item *
C<slosh1>, C<slosh2> - 1 or 2 \ lines per cell
=item *
C<grid1>, C<grid2>, C<grid4> - 1, 2, or 4 vertical and horizontal
lines per cell
=item *
C<dots1>, C<dots4>, C<dots16> - 1, 4 or 16 dots per cell
=item *
C<stipple>, C<stipple2> - see the samples
=item *
C<weave> - I hope this one is obvious.
=item *
C<cross1>, C<cross2> - 2 densities of crosshatch
=item *
C<vlozenge>, C<hlozenge> - something like lozenge tiles
=item *
C<scalesdown>, C<scalesup>, C<scalesleft>, C<scalesright> - Vaguely
like fish scales in each direction.
=item *
C<tile_L> - L-shaped tiles
=back
=item *
C<fg>, C<bg> - The C<fg> color is rendered where bits are set in the
hatch, and the C<bg> where they are clear. If you use a transparent
C<fg> or C<bg>, and set combine, you can overlay the hatch onto an
existing image.
C<fg> defaults to black, C<bg> to white.
=item *
C<dx>, C<dy> - An offset into the hatch cell. Both default to zero.
=back
A blue and white 4-pixel check pattern:
my $fill = Imager::Fill->new(hatch => "check2x2", fg => "blue");
You can call Imager::Fill->hatches for a list of hatch names.
=head2 Fountain fills
my $fill = Imager::Fill->new(fountain=>$ftype,
xa=>$xa, ya=>$ya, xb=>$xb, yb=>$yb,
segments=>$segments, repeat=>$repeat, combine=>$combine,
super_sample=>$super_sample, ssample_param=>$ssample_param);
This fills the given region with a fountain fill. This is exactly the
same fill as the C<fountain> filter, but is restricted to the shape
you are drawing, and the fountain parameter supplies the fill type,
and is required.
A radial fill from white to transparent centered on (50, 50) with a 50
pixel radius:
use Imager::Fountain;
my $segs = Imager::Fountain->simple(colors => [ "FFFFFF", "FFFFFF00" ],
positions => [ 0, 1 ]);
my $fill = Imager::Fill->new(fountain => "radial", segments => $segs,
xa => 50, ya => 50, xb => 0, yb => 50,
combine => "normal");
=head2 Image Fills
my $fill = Imager::Fill->new(image=>$src, xoff=>$xoff, yoff=>$yoff,
matrix=>$matrix, combine => $combine);
Fills the given image with a tiled version of the given image. The
first non-zero value of C<xoff> or C<yoff> will provide an offset
along the given axis between rows or columns of tiles respectively.
The matrix parameter performs a co-ordinate transformation from the
co-ordinates in the target image to the fill image co-ordinates.
Linear interpolation is used to determine the fill pixel. You can use
the L<Imager::Matrix2d> class to create transformation matrices.
The matrix parameter will significantly slow down the fill.
# some image to act as a texture
my $txim = Imager->new(...);
# simple tiling
my $fill = Imager::Fill->new(image => $txim);
( run in 1.488 second using v1.01-cache-2.11-cpan-7fcb06a456a )