App-GUI-Juliagraph

 view release on metacpan or  search on metacpan

lib/App/GUI/Juliagraph/Frame/Tab/Mapping.pm  view on Meta::CPAN


# visible tab with all visual settings

package App::GUI::Juliagraph::Frame::Tab::Mapping;
use v5.12;
use warnings;
use base qw/Wx::Panel/;
use Graphics::Toolkit::Color qw/color/;
use Wx;
use App::GUI::Juliagraph::Widget::SliderStep;
use App::GUI::Juliagraph::Widget::SliderCombo;
use App::GUI::Juliagraph::Widget::ProgressBar;

my $default_settings =  {
        custom_partition => 0, scale_steps => 20, scale_distro => 'square',
        user_colors => 1, begin_color => 'color 2', end_color => 'color 4', background_color => 'black',
        gradient_dynamic => 0, gradient_space => 'HSL',
        use_subgradient => 0, subgradient_size => 500, subgradient_steps => 5,
        subgradient_dynamic => 0, subgradient_space => 'HSL', subgradient_distro => 'sqrt',
    };

sub new {
    my ( $class, $parent ) = @_;

    my $self = $class->SUPER::new( $parent, -1);
    $self->{'callback'} = sub {};
    $self->{'tab'}{'color'} = '';

    my $map_lbl = Wx::StaticText->new($self, -1, 'C o l o r   G r a d i e n t : ' );
    my $color_lbl = Wx::StaticText->new($self, -1, 'User Colors : ' );
    $self->{'lbl_backg'} = Wx::StaticText->new($self, -1, 'Background : ' );
    $self->{'lbl_begin'} = Wx::StaticText->new($self, -1, 'Begin : ' );
    $self->{'lbl_end'}   = Wx::StaticText->new($self, -1, 'End : ' );
    my $map_dyn_lbl = Wx::StaticText->new($self, -1, 'Dynamic : ' );
    my $map_space_lbl = Wx::StaticText->new($self, -1, 'Space : ' );
    my $scale_lbl = Wx::StaticText->new($self, -1, 'P a r t i t i o n i n g   T h e   I t e r a t i o n   S c a l e : ' );
    my $custom_lbl = Wx::StaticText->new($self, -1, 'Custom : ' );
    $self->{'lbl_max'} = Wx::StaticText->new($self, -1, 'Iterations (Size) : ' );
    $self->{'lbl_distro'} = Wx::StaticText->new($self, -1, 'Distribution : ' );
    my $submap_lbl = Wx::StaticText->new($self, -1, 'S u b   G r a d i e n t : ' );
    $self->{'lbl_sub_use'} = Wx::StaticText->new($self, -1, 'Activate : ' );
    $self->{'lbl_sub_dyn'} = Wx::StaticText->new($self, -1, 'Dynamic : ' );
    $self->{'lbl_sub_space'} = Wx::StaticText->new($self, -1, 'Space : ' );
    $self->{'lbl_sub_distro'} = Wx::StaticText->new($self, -1, 'Distribution : ' );
    $map_lbl->SetToolTip('Decide which colors are used to paint the drawing.');
    $color_lbl->SetToolTip('Use slected colors (on) or just simple gray scale (off)');
    $self->{'lbl_backg'}->SetToolTip('Which color is used to paint areas where computation never exceeds the bailout value.');
    $self->{'lbl_begin'}->SetToolTip('Starting color of the rainbow.');
    $self->{'lbl_end'}->SetToolTip('Endcolor of the rainbow');
    $map_dyn_lbl->SetToolTip('How many big is the slant of a color gradient in one or another direction (between the selected colors in next tab)');
    $map_space_lbl->SetToolTip('In which color space will the gradient between chosen colors be computed ?');
    $scale_lbl->SetToolTip('Divide the scale of possible iterations into goups (partitions) that can be mapped to colors.');
    $custom_lbl->SetToolTip('Divide the scale of possible iterations into goups (partitions) that can be mapped to colors. Use every iteration count gets its own color when off.');
    $self->{'lbl_max'}->SetToolTip('Maximal iteration count that gets partitioned.');
    $self->{'lbl_distro'}->SetToolTip('How to compute the partitioning of the iteration scale. Linear means evenly sized portions.');
    $submap_lbl->SetToolTip('Gradients between areas of iteration counts based on final value.');
    $self->{'lbl_sub_use'}->SetToolTip('Make even more fine grained color gradients, my computing gradient between color regions.');
    $self->{'lbl_sub_dyn'}->SetToolTip('How big is the slant of a color sub gradient in one or another direction ?');
    $self->{'lbl_sub_space'}->SetToolTip('In which color space will the subgradient between chosen colors be computed ?');

    my @color_names = map { 'color '.$_ } 1 .. 11;
    $self->{'custom_partition'} = Wx::CheckBox->new( $self, -1,  '', [-1,-1],[30, -1]);
    $self->{'user_colors'}      = Wx::CheckBox->new( $self, -1,  '', [-1,-1],[30, -1]);
    $self->{'use_subgradient'}  = Wx::CheckBox->new( $self, -1,  '', [-1,-1],[30, -1]);
    $self->{'scale_steps'}  = App::GUI::Juliagraph::Widget::SliderCombo->new( $self, 252, 'Steps :', "In how many parts the scale (0 .. max) will be partitioned, meaning: how many different colors/shades we use to paint the fractal", 2, 100, 20);
    $self->{'scale_max'}    = Wx::TextCtrl->new( $self, -1,         0, [-1,-1], [60, -1], &Wx::wxTE_RIGHT | &Wx::wxTE_READONLY);
    $self->{'scale_distro'} = Wx::ComboBox->new( $self, -1, 'linear',  [-1,-1],[100, -1], [qw/log cubert sqrt linear square cube exp/]);
    $self->{'begin_color'}  = Wx::ComboBox->new( $self, -1, 'color 3', [-1,-1],[100, -1], [@color_names]);
    $self->{'end_color'}    = Wx::ComboBox->new( $self, -1, 'color 4', [-1,-1],[100, -1], [@color_names]);
    $self->{'background_color'}   = Wx::ComboBox->new( $self, -1,'black', [-1,-1],[100,-1], [qw/black blue gray white/, 'color 11']);
    $self->{'gradient_dynamic'}   = Wx::ComboBox->new( $self, -1,      0, [-1,-1],[80, -1], [-5, -4, -3, -2.5, -2, -1.6, -1.3, -1, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1, 1.3, 1.6, 2, 2.5, 3, 4, 5...
    $self->{'gradient_space'}     = Wx::ComboBox->new( $self, -1,  'RGB', [-1,-1],[80, -1], [qw/RGB HSL/]);
    $self->{'subgradient_steps'}  = App::GUI::Juliagraph::Widget::SliderCombo->new( $self, 249, 'Steps :', "How man shades toes the subgradient have ?", 2, 100, 5, 1);
    $self->{'subgradient_size'}   = App::GUI::Juliagraph::Widget::SliderCombo->new( $self, 249, 'Size :', "Up to which value (Bailout/Stop Value + X) does the scale goes, from which subgradient is computed", 100, 5000, 500, 50);
    $self->{'subgradient_space'}  = Wx::ComboBox->new( $self, -1,  'RGB', [-1,-1],[80, -1], [qw/RGB HSL/]);
    $self->{'subgradient_dynamic'}= Wx::ComboBox->new($self, -1,     0, [-1,-1],[80, -1], [-5, -4, -3, -2.5, -2, -1.6, -1.3, -1, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1, 1.3, 1.6, 2, 2.5, 3, 4, 5])...
    $self->{'subgradient_distro'} = Wx::ComboBox->new( $self, -1, 'linear',  [-1,-1],[100, -1], [qw/log cubert sqrt linear square cube exp/]);
    $self->{'custom_partition'}->SetToolTip('Divide the scale of possible iterations into goups (partitions) that can be mapped to colors. Use every iteration count gets its own color when off.');
    $self->{'scale_max'}->SetToolTip('Maximal iteration count.');
    $self->{'scale_distro'}->SetToolTip('Relation between partitions size wise, linear means they all equally big.');
    $self->{'user_colors'}->SetToolTip('Use chosen color selection to compute color rainbow (on) or just a gray scale (off).');
    $self->{'use_subgradient'}->SetToolTip('Make color gradient smoother by computing gradients between colored areas based on final value of iteration.');
    $self->{'begin_color'}->SetToolTip('Starting color of the rainbow.');
    $self->{'end_color'}->SetToolTip('Endcolor of the rainbow');
    $self->{'background_color'}->SetToolTip('Color that is used to paint areas where iteration stays below stop value.');
    $self->{'gradient_dynamic'}->SetToolTip('Skew direction of gradient (positive value = left)');
    $self->{'subgradient_dynamic'}->SetToolTip('Skew direction of gradient (positive value = left)');
    $self->{'subgradient_distro'}->SetToolTip('Relation between parts of subgradient size wise');
    $self->{'color_rainbow'}      = App::GUI::Juliagraph::Widget::ProgressBar->new( $self, 450, 30, [20, 20, 110]);
    $self->{'background_rainbow'} = App::GUI::Juliagraph::Widget::ProgressBar->new( $self, 450, 10, [20, 20, 110]);
    $self->{'color_rainbow'}->SetToolTip('Color gradient display.');
    $self->{'background_rainbow'}->SetToolTip('Background color display.');

    Wx::Event::EVT_CHECKBOX( $self, $self->{'custom_partition'},sub { $self->enable_partition($self->{'custom_partition'}->GetValue); $self->{'callback'}->() });
    Wx::Event::EVT_CHECKBOX( $self, $self->{'user_colors'},     sub { $self->enable_user_colors($self->{'user_colors'}->GetValue);    $self->{'callback'}->() });
    Wx::Event::EVT_CHECKBOX( $self, $self->{'use_subgradient'}, sub { $self->enable_subgradient($self->{'use_subgradient'}->GetValue);$self->{'callback'}->() });
    Wx::Event::EVT_COMBOBOX( $self, $self->{$_},                sub { $self->update_max_color; $self->{'callback'}->() })
        for qw/begin_color end_color/;
    Wx::Event::EVT_COMBOBOX( $self, $self->{$_},                sub { $self->{'callback'}->() })
        for qw/scale_distro gradient_dynamic gradient_space background_color
               subgradient_distro subgradient_dynamic subgradient_space/;
    $self->{$_}->SetCallBack( sub { $self->{'callback'}->(); }) for qw/scale_steps subgradient_size subgradient_steps/;

    my $std_margin = 20;
    my $std  = &Wx::wxALIGN_LEFT | &Wx::wxALIGN_CENTER_VERTICAL | &Wx::wxGROW;



( run in 0.639 second using v1.01-cache-2.11-cpan-39bf76dae61 )