| 1 |
package Imager::Filter::Mandelbrot; |
| 2 |
use 5.006; |
| 3 |
use strict; |
| 4 |
use Imager; |
| 5 |
|
| 6 |
BEGIN { |
| 7 |
our $VERSION = "0.05"; |
| 8 |
|
| 9 |
require XSLoader; |
| 10 |
XSLoader::load('Imager::Filter::Mandelbrot', $VERSION); |
| 11 |
} |
| 12 |
|
| 13 |
sub _mandelbrot { |
| 14 |
my %hsh = @_; |
| 15 |
|
| 16 |
mandelbrot($hsh{image}, $hsh{minx}, $hsh{miny}, $hsh{maxx}, $hsh{maxy}, $hsh{maxiter}); |
| 17 |
} |
| 18 |
|
| 19 |
my %defaults = |
| 20 |
( |
| 21 |
minx => -2.5, |
| 22 |
maxx => 1.5, |
| 23 |
miny => -1.5, |
| 24 |
maxy => 1.5, |
| 25 |
maxiter => 256, |
| 26 |
); |
| 27 |
|
| 28 |
my @callseq = qw/image minx miny maxx maxy maxiter/; |
| 29 |
|
| 30 |
Imager->register_filter(type=>'mandelbrot', |
| 31 |
callsub => \&_mandelbrot, |
| 32 |
defaults => \%defaults, |
| 33 |
callseq => \@callseq); |
| 34 |
|
| 35 |
1; |
| 36 |
|
| 37 |
__END__ |
| 38 |
|
| 39 |
=head1 NAME |
| 40 |
|
| 41 |
Imager::Filter::Mandelbrot - filter that renders the Mandelbrot set. |
| 42 |
|
| 43 |
=head1 SYNOPSIS |
| 44 |
|
| 45 |
use Imager; |
| 46 |
use Imager::Filter::Mandelbrot; |
| 47 |
|
| 48 |
$img->filter(type=>'mandelbrot', ...); |
| 49 |
|
| 50 |
=head1 DESCRIPTION |
| 51 |
|
| 52 |
This is a expansion of the C<mandelbrot> dynamically loadable filter |
| 53 |
provided in C<dynfilt> in previous releases of Imager. |
| 54 |
|
| 55 |
Valid filter parameters are: |
| 56 |
|
| 57 |
=over |
| 58 |
|
| 59 |
=item * |
| 60 |
|
| 61 |
C<minx>, C<maxx> - the range of x values to render. Defaults: -2.5, 1.5. |
| 62 |
|
| 63 |
=item * |
| 64 |
|
| 65 |
C<miny>, C<maxy> - the range of y values to render. Defaults: -1.5, 1.5 |
| 66 |
|
| 67 |
=item * |
| 68 |
|
| 69 |
C<maxiter> - the maximum number of iterations to perform when checking |
| 70 |
if the sequence tend towards infinity. |
| 71 |
|
| 72 |
=back |
| 73 |
|
| 74 |
=head1 AUTHOR |
| 75 |
|
| 76 |
Original by Arnar M. Hrafnkelsson. |
| 77 |
|
| 78 |
Adapted and expanded by Tony Cook <[email protected]> |
| 79 |
|
| 80 |
=head1 SEE ALSO |
| 81 |
|
| 82 |
Imager, Imager::Filters. |
| 83 |
|
| 84 |
=cut |