add examples to the Imager::Fill documentation
authorTony Cook <tony@develop-help.com>
Fri, 19 Oct 2012 11:54:01 +0000 (22:54 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 19 Oct 2012 11:54:01 +0000 (22:54 +1100)
lib/Imager/Fill.pm

index 057bd2a12b149b45cec428d095a294449b706f4b..2997853df8f8565eb7675b985694d210ac938e6c 100644 (file)
@@ -256,6 +256,10 @@ objects they should have the same type.
 Creates a solid fill, the only required parameter is C<solid> which
 should be the color to fill with.
 
+A translucent red fill:
+
+  my $red = Imager::Fill->new(solid => "FF000080", combine => "normal");
+
 =head2 Hatched fills
 
   my $fill = Imager::Fill->new(hatch=>$type, fg=>$fgcolor, bg=>$bgcolor,
@@ -349,6 +353,10 @@ C<dx>, C<dy> - An offset into the hatch cell.  Both default to zero.
 
 =back
 
+A blue and white 4-pixel check patten:
+
+  my $fill = Imager::Fill->new(hatch => "check2x2", fg => "blue");
+
 You can call Imager::Fill->hatches for a list of hatch names.
 
 =head2 Fountain fills
@@ -363,6 +371,17 @@ 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,
@@ -379,6 +398,23 @@ 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);
+
+  # tile with a vertical offset
+  my $fill = Imager::Fill->new(image => $txim, yoff => 10);
+
+  # tile with a horizontal offset
+  my $fill = Imager::Fill->new(image => $txim, xoff => 10);
+
+  # rotated
+  use Imager::Matrix2d;
+  my $fill = Imager::Fill->new(image => $txim,
+                matrix => Imager::Matrix2d->rotate(degrees => 20));
+
 =head2 Opacity modification fill
 
   my $fill = Imager::Fill->new(type => "opacity",
@@ -409,6 +445,9 @@ opacity - multiplier for the source fill opacity.  Default: 0.5.
 
 The source fills combine mode is used.
 
+  my $hatch = Imager::Fill->new(hatch => "check4x4", combine => "normal");
+  my $fill = Imager::Fill->new(type => "opacity", other => $hatch);
+
 =head1 OTHER METHODS
 
 =over