view release on metacpan or search on metacpan
lib/App/GUI/Juliagraph.pm view on Meta::CPAN
Mandelbrot (first two pictures) and Julia fractals (four after that) are
just mathematical diagrams, showing you how iterating the equation
C<z_n+1 = z_n ** 2 + C> behaves on the complex plane.
Our running variable gets an initial value and gets squared each time,
plus an constant is added, also each time. Mandelbrot mean this constant
are the pixel coordinates, Julia means the coordinates are the starting
value. And the pixel color just contains the information how many
iterations (times) it took until z got greater than our bailout value.
=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/examples/first.png" alt="" width="300" height="300">
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/examples/first_detail.png" alt="" width="300" height="300">
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/examples/feingoldkreutz.png"alt="" width="300" height="300">
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/examples/julia.png" alt="" width="300" height="300">
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/examples/set.png" alt="" width="300" height="300">
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/examples/sonne.png" alt="" width="300" height="300">
</p>
This program has additional capabilities/options:
=over 4
=item *
iteration formula with up to four monomials
lib/App/GUI/Juliagraph.pm view on Meta::CPAN
Please mind the tool tips - short help texts which appear if the mouse
stands still over a button. Also helpful are messages in the status bar
at the bottom that appear while browsing the menu. Please take also special
note at the I<mouse> section since you can browse the fractals by mouse.
=head2 Constraints
=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/POD/Tab_Constraints.png" alt="" width="630" height="410">
</p>
The controls on the first tab panel are the settings that define most of
the rules by which the equation is computed. The page is divided from top
to bottom into 5 sections that will be discussed in that order.
The first section allows you to set the fractal type: I<Mandelbrot>,
I<Julia>, of something in between (option I<Any>). If you choose I<Mandelbrot>,
the sections 3 and 4 get blurred and set to zero, since the play no role
in computing this type of fractal. If chosen I<Julia> only section 4 is
lib/App/GUI/Juliagraph.pm view on Meta::CPAN
When the computation runs out of iterations, the current pixel will get
the background color. The second stop criterion is fulfilled when
the value exceeds the bailout limit (I<Value>), which is also the displayed
number squared. In the right corner you got ten different ways how to compute
the amount of z. Mathematicians call them merics. They mostly influence
the shape around the main shape (the crwon - corona).
=head2 Monomials
=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/POD/Tab_Polynomials.png" alt="" width="630" height="410">
</p>
The second tab contains 4 identical sections which also work the same way.
Each of them stand in for a monomial of the iteration equation, but only
if the checkbox I<On> is marked. A second checkbox decides if this monomial
gets added or subtracted. The third allows you discard the complex factor
below the checkboxes. The fourth checkbox allows you to use the current
pixel coordinates as second factor in the monomial. Please be aware this
option can only be chosen if fractal type C<Any> is active and the I<Monomial>
checkbox in the upper right corner is on. Both of these settings are on
lib/App/GUI/Juliagraph.pm view on Meta::CPAN
a complex logarithm of the power term z^n. This is useful when combined
with a very larg factor or another monomial. This just mentioned power
C<n> ca be chosen right beside the checkboxes. The higher this power is,
the longer it takes to calculate the picture, but it adds also a nice
rotational symmetry. C<Mandelbrot> has a (n-1)-times rot symmetry and
C<Julia> a n-times rotational symmetry.
=head2 Color Mapping
=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/POD/Tab_Mapping.png" alt="" width="630" height="410">
</p>
This page is about mapping the iteration number at bailout to a color.
To be able to do that better you can preview here the color rainbow
between the first and second section. Below the color rainbow is another
this monochrome strip. It displayes the currently active background color.
The rainbow is from left (low iteration number) to right (high).
The first section starts with a checkbox. When deselected, the fractal
gets a gray scale. When selected all color choices are in effect. The
lib/App/GUI/Juliagraph.pm view on Meta::CPAN
above just lands in the last bucket. The subgradient can again be skewed
by a C<Distribution> and C<Dynamic> value (as described above). Also
the resulting color change dependant in which color C<Space> it is
computed in. I<RBG> gives usually more smooth results and I<HSL> more
contrast.
=head2 Colors
=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Juliagraph/master/img/POD/Tab_Color.png" alt="" width="630" height="410">
</p>
This page helps you to select the color that will be used to paint the fractal.
You can see them in the middle row.
The background color is often the one at the most left. That is why it
is marked by a vertical bar. The colors are numbered from left to right
with 1 to 11.
The first section on the pages is for loading and saving custom sets of
colors. Please use the delete button carefully. C<New> saves the current
lib/App/GUI/Juliagraph/Config/Default.pm view on Meta::CPAN
#
package App::GUI::Juliagraph::Config::Default;
use v5.12;
use warnings;
our $data = {
file_base_dir => '~',
file_base_ending => 'png',
image_size => 600,
open_dir => '~',
save_dir => '~',
write_dir => '~',
last_settings => [],
tips => 1,
color_set => {
basic => [ 'black', 'red', 'lime', 'blue', 'white', 'grey', 'grey', 'grey','grey','grey','grey' ],
dawn => [ 'black', '#f9d87b','#936d1a','#bf3136','#8f1416','#99158b','#1d1d7c','#111111','black','grey','grey' ],
day => [ 'black', '#ffcf3d','#e25555','#e65c60','#4acfab','#48614a','gray20', '#111111','black','grey','grey' ],
lib/App/GUI/Juliagraph/Frame.pm view on Meta::CPAN
});
}
$image_size_menu->Check( 12100 +($self->{'config'}->get_value('image_size') / 100), 1);
my $image_format_menu = Wx::Menu->new();
$image_format_menu->AppendRadioItem(12201, 'PNG', "set default image format to PNG");
$image_format_menu->AppendRadioItem(12202, 'JPEG', "set default image format to JPEG");
$image_format_menu->AppendRadioItem(12203, 'SVG', "set default image format to SVG");
Wx::Event::EVT_MENU( $self, 12201, sub { $self->{'config'}->set_value('file_base_ending', 'png') });
Wx::Event::EVT_MENU( $self, 12202, sub { $self->{'config'}->set_value('file_base_ending', 'jpg') });
Wx::Event::EVT_MENU( $self, 12203, sub { $self->{'config'}->set_value('file_base_ending', 'svg') });
$image_format_menu->Check( 12201, 1 ) if $self->{'config'}->get_value('file_base_ending') eq 'png';
$image_format_menu->Check( 12202, 1 ) if $self->{'config'}->get_value('file_base_ending') eq 'jpg';
$image_format_menu->Check( 12203, 1 ) if $self->{'config'}->get_value('file_base_ending') eq 'svg';
my $image_menu = Wx::Menu->new();
$image_menu->Append( 12300, "&Draw\tCtrl+D", "complete a sketch drawing" );
$image_menu->Append( 12100, "S&ize", $image_size_menu, "set image size" );
$image_menu->Append( 12200, "&Format", $image_format_menu, "set default image formate" );
$image_menu->Append( 12400, "&Save\tCtrl+S", "save currently displayed image" );
my $help_menu = Wx::Menu->new();
lib/App/GUI/Juliagraph/Frame.pm view on Meta::CPAN
return if -e $path and
Wx::MessageDialog->new( $self, "\n\nReally overwrite the settings file?", 'Confirmation Question',
&Wx::wxYES_NO | &Wx::wxICON_QUESTION )->ShowModal() != &Wx::wxID_YES;
$self->write_settings_file( $path );
my $dir = App::GUI::Juliagraph::Settings::extract_dir( $path );
$self->{'config'}->set_value('write_dir', $dir);
}
sub save_image_dialog {
my ($self) = @_;
my @wildcard = ( 'SVG files (*.svg)|*.svg', 'PNG files (*.png)|*.png', 'JPEG files (*.jpg)|*.jpg');
my $wildcard = '|All files (*.*)|*.*';
my $default_ending = $self->{'config'}->get_value('file_base_ending');
$wildcard = ($default_ending eq 'jpg') ? ( join '|', @wildcard[2,1,0]) . $wildcard :
($default_ending eq 'png') ? ( join '|', @wildcard[1,0,2]) . $wildcard :
( join '|', @wildcard[0,1,2]) . $wildcard ;
my @wildcard_ending = ($default_ending eq 'jpg') ? (qw/jpg png svg/) :
($default_ending eq 'png') ? (qw/png svg jpg/) :
(qw/svg jpg png/) ;
my $dialog = Wx::FileDialog->new ( $self, "select a file name to save image", $self->{'config'}->get_value('save_dir'), '', $wildcard, &Wx::wxFD_SAVE );
return if $dialog->ShowModal == &Wx::wxID_CANCEL;
my $path = $dialog->GetPath;
return if -e $path and
Wx::MessageDialog->new( $self, "\n\nReally overwrite the image file?", 'Confirmation Question',
&Wx::wxYES_NO | &Wx::wxICON_QUESTION )->ShowModal() != &Wx::wxID_YES;
my $file_ending = lc substr ($path, -4);
unless ($dialog->GetFilterIndex == 3 or # filter set to all endings
($file_ending eq '.jpg' or $file_ending eq '.png' or $file_ending eq '.svg')){
$path .= '.' . $wildcard_ending[$dialog->GetFilterIndex];
}
my $ret = $self->write_image( $path );
if ($ret){ $self->SetStatusText( $ret, 0 ) }
else { $self->{'config'}->set_value('save_dir', App::GUI::Juliagraph::Settings::extract_dir( $path )) }
}
sub open_setting_file {
my ($self, $file ) = @_;
my $settings = App::GUI::Juliagraph::Settings::load( $file );
lib/App/GUI/Juliagraph/Frame/Panel/Board.pm view on Meta::CPAN
$dc->DrawBitmap( Wx::Bitmap->new( $img ), 0, 0, 0 ); # at point (0, 0) with no mask
$self->{'image'} = $img unless $self->{'flag'}{'sketch'};
delete $self->{'flag'};
$dc;
}
sub save_file {
my( $self, $file_name, $width, $height ) = @_;
my $file_end = lc substr( $file_name, -3 );
if ($file_end eq 'svg') { $self->save_svg_file( $file_name, $width, $height ) }
elsif ($file_end eq 'png' or $file_end eq 'jpg') { $self->save_bmp_file( $file_name, $file_end, $width, $height ) }
else { return "unknown file ending: '$file_end'" }
}
sub save_svg_file {
my( $self, $file_name, $width, $height ) = @_;
$width //= $self->GetParent->{'config'}->get_value('image_size');
$height //= $self->GetParent->{'config'}->get_value('image_size');
$width //= $self->{'size'}{'x'};
$height //= $self->{'size'}{'y'};
my $dc = Wx::SVGFileDC->new( $file_name, $width, $height, 250 ); # 250 dpi
lib/App/GUI/Juliagraph/Frame/Panel/Board.pm view on Meta::CPAN
$height //= $self->GetParent->{'config'}->get_value('image_size');
$width //= $self->{'size'}{'x'};
$height //= $self->{'size'}{'y'};
# reuse $set->{'image'}
my $bmp = Wx::Bitmap->new( $width, $height, 24); # bit depth
my $dc = Wx::MemoryDC->new( );
$dc->SelectObject( $bmp );
$self->paint( $dc, $width, $height);
# $dc->Blit (0, 0, $width, $height, $self->{'dc'}, 10, 10 + $self->{'menu_size'});
$dc->SelectObject( &Wx::wxNullBitmap );
$bmp->SaveFile( $file_name, $file_end eq 'png' ? &Wx::wxBITMAP_TYPE_PNG : &Wx::wxBITMAP_TYPE_JPEG );
}
1;