… | |
… | |
301 | |
301 | |
302 | sub clone($) { |
302 | sub clone($) { |
303 | $_[0]->clone |
303 | $_[0]->clone |
304 | } |
304 | } |
305 | |
305 | |
|
|
306 | =item merge $img ... |
|
|
307 | |
|
|
308 | Takes any number of images and merges them together, creating a single |
|
|
309 | image containing them all. |
|
|
310 | |
|
|
311 | =cut |
|
|
312 | |
|
|
313 | sub merge(@) { |
|
|
314 | # rather annoyingly clumsy, but optimisation is for another time |
|
|
315 | |
|
|
316 | my $x0 = 1e9; |
|
|
317 | my $y0 = 1e9; |
|
|
318 | my $x1 = -1e9; |
|
|
319 | my $y1 = -1e9; |
|
|
320 | |
|
|
321 | for (@_) { |
|
|
322 | my ($x, $y, $w, $h) = $_->geometry; |
|
|
323 | |
|
|
324 | $x0 = $x if $x0 > $x; |
|
|
325 | $y0 = $y if $y0 > $y; |
|
|
326 | |
|
|
327 | $x += $w; |
|
|
328 | $y += $h; |
|
|
329 | |
|
|
330 | $x1 = $x if $x1 > $x; |
|
|
331 | $y1 = $y if $y1 > $y; |
|
|
332 | } |
|
|
333 | |
|
|
334 | my $base = $self->new_img ($x0, $y0, $x1 - $x0, $y1 - $y0); |
|
|
335 | $base->fill ([0, 0, 0, 0]); |
|
|
336 | |
|
|
337 | $base->blend (1., $_) |
|
|
338 | for @_; |
|
|
339 | |
|
|
340 | $base |
|
|
341 | } |
|
|
342 | |
306 | =head2 TILING MODES |
343 | =head2 TILING MODES |
307 | |
344 | |
308 | The following operators modify the tiling mode of an image, that is, the |
345 | The following operators modify the tiling mode of an image, that is, the |
309 | way that pixels outside the image area are painted when the image is used. |
346 | way that pixels outside the image area are painted when the image is used. |
310 | |
347 | |
… | |
… | |
761 | |
798 | |
762 | =back |
799 | =back |
763 | |
800 | |
764 | =head2 OTHER STUFF |
801 | =head2 OTHER STUFF |
765 | |
802 | |
766 | Anything that didn't fit any of the other categories, even after appliyng |
803 | Anything that didn't fit any of the other categories, even after applying |
767 | force and closing our eyes. |
804 | force and closing our eyes. |
768 | |
805 | |
769 | =over 4 |
806 | =over 4 |
770 | |
807 | |
771 | =item once { ... } |
808 | =item once { ... } |