1Imager::Fill(3) User Contributed Perl Documentation Imager::Fill(3)
2
3
4
6 Imager::Fill - general fill types
7
9 use Imager;
10 use Imager::Fill;
11
12 my $fill1 = Imager::Fill->new(solid=>$color, combine=>$combine);
13 my $fill2 = Imager::Fill->new(hatch=>'vline2', fg=>$color1, bg=>$color2,
14 dx=>$dx, dy=>$dy);
15 my $fill3 = Imager::Fill->new(fountain=>$type, ...);
16 my $fill4 = Imager::Fill->new(image=>$img, ...);
17 my $fill5 = Imager::Fill->new(type => "opacity", other => $fill,
18 opacity => ...);
19
21 Creates fill objects for use by most filled area drawing functions.
22
23 All fills are created with the new method.
24
25 new
26 my $fill = Imager::Fill->new(...);
27
28 The parameters depend on the type of fill being created. See below
29 for details.
30
31 The currently available fills are:
32
33 · solid
34
35 · hatch
36
37 · fountain (similar to gradients in paint software)
38
39 · image - fill with an image, possibly transformed
40
41 · opacity - a lower opacity version of some other fill
42
44 combine
45 The way in which the fill data is combined with the underlying
46 image. See "Combine Types" in Imager::Draw.
47
48 In general colors can be specified as Imager::Color or
49 Imager::Color::Float objects. The fill object will typically store
50 both types and convert from one to the other. If a fill takes 2 color
51 objects they should have the same type.
52
53 Solid fills
54 my $fill = Imager::Fill->new(solid=>$color, combine =>$combine)
55
56 Creates a solid fill, the only required parameter is "solid" which
57 should be the color to fill with.
58
59 A translucent red fill:
60
61 my $red = Imager::Fill->new(solid => "FF000080", combine => "normal");
62
63 Hatched fills
64 my $fill = Imager::Fill->new(hatch=>$type, fg=>$fgcolor, bg=>$bgcolor,
65 dx=>$dx, $dy=>$dy);
66
67 Creates a hatched fill. You can specify the following keywords:
68
69 · "hatch" - The type of hatch to perform, this can either be the
70 numeric index of the hatch (not recommended), the symbolic name of
71 the hatch, or an array of 8 integers which specify the pattern of
72 the hatch.
73
74 Hatches are represented as cells 8x8 arrays of bits, which limits
75 their complexity.
76
77 Current hatch names are:
78
79 · "check1x1", "check2x2", "check4x4" - checkerboards at various
80 sizes
81
82 · "vline1", "vline2", "vline4" - 1, 2, or 4 vertical lines per
83 cell
84
85 · "hline1", "hline2", "hline4" - 1, 2, or 4 horizontal lines per
86 cell
87
88 · "slash1", "slash2" - 1 or 2 / lines per cell.
89
90 · "slosh1", "slosh2" - 1 or 2 \ lines per cell
91
92 · "grid1", "grid2", "grid4" - 1, 2, or 4 vertical and horizontal
93 lines per cell
94
95 · "dots1", "dots4", "dots16" - 1, 4 or 16 dots per cell
96
97 · "stipple", "stipple2" - see the samples
98
99 · "weave" - I hope this one is obvious.
100
101 · "cross1", "cross2" - 2 densities of crosshatch
102
103 · "vlozenge", "hlozenge" - something like lozenge tiles
104
105 · "scalesdown", "scalesup", "scalesleft", "scalesright" - Vaguely
106 like fish scales in each direction.
107
108 · "tile_L" - L-shaped tiles
109
110 · "fg", "bg" - The "fg" color is rendered where bits are set in the
111 hatch, and the "bg" where they are clear. If you use a transparent
112 "fg" or "bg", and set combine, you can overlay the hatch onto an
113 existing image.
114
115 "fg" defaults to black, "bg" to white.
116
117 · "dx", "dy" - An offset into the hatch cell. Both default to zero.
118
119 A blue and white 4-pixel check pattern:
120
121 my $fill = Imager::Fill->new(hatch => "check2x2", fg => "blue");
122
123 You can call Imager::Fill->hatches for a list of hatch names.
124
125 Fountain fills
126 my $fill = Imager::Fill->new(fountain=>$ftype,
127 xa=>$xa, ya=>$ya, xb=>$xb, yb=>$yb,
128 segments=>$segments, repeat=>$repeat, combine=>$combine,
129 super_sample=>$super_sample, ssample_param=>$ssample_param);
130
131 This fills the given region with a fountain fill. This is exactly the
132 same fill as the "fountain" filter, but is restricted to the shape you
133 are drawing, and the fountain parameter supplies the fill type, and is
134 required.
135
136 A radial fill from white to transparent centered on (50, 50) with a 50
137 pixel radius:
138
139 use Imager::Fountain;
140 my $segs = Imager::Fountain->simple(colors => [ "FFFFFF", "FFFFFF00" ],
141 positions => [ 0, 1 ]);
142 my $fill = Imager::Fill->new(fountain => "radial", segments => $segs,
143 xa => 50, ya => 50, xb => 0, yb => 50,
144 combine => "normal");
145
146 Image Fills
147 my $fill = Imager::Fill->new(image=>$src, xoff=>$xoff, yoff=>$yoff,
148 matrix=>$matrix, combine => $combine);
149
150 Fills the given image with a tiled version of the given image. The
151 first non-zero value of "xoff" or "yoff" will provide an offset along
152 the given axis between rows or columns of tiles respectively.
153
154 The matrix parameter performs a co-ordinate transformation from the co-
155 ordinates in the target image to the fill image co-ordinates. Linear
156 interpolation is used to determine the fill pixel. You can use the
157 Imager::Matrix2d class to create transformation matrices.
158
159 The matrix parameter will significantly slow down the fill.
160
161 # some image to act as a texture
162 my $txim = Imager->new(...);
163
164 # simple tiling
165 my $fill = Imager::Fill->new(image => $txim);
166
167 # tile with a vertical offset
168 my $fill = Imager::Fill->new(image => $txim, yoff => 10);
169
170 # tile with a horizontal offset
171 my $fill = Imager::Fill->new(image => $txim, xoff => 10);
172
173 # rotated
174 use Imager::Matrix2d;
175 my $fill = Imager::Fill->new(image => $txim,
176 matrix => Imager::Matrix2d->rotate(degrees => 20));
177
178 Opacity modification fill
179 my $fill = Imager::Fill->new(type => "opacity",
180 other => $fill, opacity => 0.25);
181
182 This can be used to make a fill that is a more translucent or opaque
183 version of an existing fill. This is intended for use where you
184 receive a fill object as a parameter and need to change the opacity.
185
186 Parameters:
187
188 · type => "opacity" - Required
189
190 · other - the fill to produce a modified version of. This must be an
191 Imager::Fill object. Required.
192
193 · opacity - multiplier for the source fill opacity. Default: 0.5.
194
195 The source fills combine mode is used.
196
197 my $hatch = Imager::Fill->new(hatch => "check4x4", combine => "normal");
198 my $fill = Imager::Fill->new(type => "opacity", other => $hatch);
199
201 Imager::Fill->hatches
202 A list of all defined hatch names.
203
204 Imager::Fill->combines
205 A list of all combine types.
206
208 I'm planning on adding the following types of fills:
209
210 · "checkerboard" - combines 2 other fills in a checkerboard
211
212 · "combine" - combines 2 other fills using the levels of an image
213
214 · "regmach" - uses the transform2() register machine to create fills
215
217 Tony Cook <tony@develop-help.com>
218
220 Imager(3)
221
222
223
224perl v5.30.0 2019-07-26 Imager::Fill(3)