App-GUI-Cellgraph

 view release on metacpan or  search on metacpan

lib/App/GUI/Cellgraph/Dialog/About.pm  view on Meta::CPAN

use v5.12;
use warnings;
use Wx;

package App::GUI::Cellgraph::Dialog::About;
use base qw/Wx::Dialog/;
use Graphics::Toolkit::Color;

sub new {
    my ( $class, $parent) = @_;
    my $self = $class->SUPER::new( $parent, -1, 'About Wx::GUI::Cellgraph' );

    my @label_property = ( [-1,-1], [-1,-1], &Wx::wxALIGN_CENTRE_HORIZONTAL );
    my $version = Wx::StaticText->new( $self, -1, $App::GUI::Cellgraph::NAME . '    version '.$App::GUI::Cellgraph::VERSION , @label_property);
    my $author  = Wx::StaticText->new( $self, -1, ' by Herbert Breunung ', @label_property);
    my $license = Wx::StaticText->new( $self, -1, ' licensed under the GPL 3 ', @label_property);
    my $perl    = Wx::StaticText->new( $self, -1, 'using Perl '.$^V, @label_property);
    my $wx      = Wx::StaticText->new( $self, -1, 'WxPerl '. $Wx::VERSION . '  ( '. &Wx::wxVERSION_STRING. ' )', @label_property);
    my $gtc     = Wx::StaticText->new( $self, -1, 'Graphics::Toolkit::Color  '.$Graphics::Toolkit::Color::VERSION, @label_property);
    my $hd      = Wx::StaticText->new( $self, -1, 'File::HomeDir  '.$File::HomeDir::VERSION, @label_property);
    my $url_lbl = Wx::StaticText->new( $self, -1, 'latest version on CPAN:   ', @label_property);

lib/App/GUI/Cellgraph/Frame.pm  view on Meta::CPAN

use App::GUI::Cellgraph::Frame::Tab::Rules;
use App::GUI::Cellgraph::Frame::Tab::Action;
use App::GUI::Cellgraph::Frame::Tab::Color;
use App::GUI::Cellgraph::Frame::Panel::Board;
use App::GUI::Cellgraph::Widget::ProgressBar;
use App::GUI::Cellgraph::Settings;
use App::GUI::Cellgraph::Config;

sub new {
    my ( $class, $parent, $title ) = @_;
    my $self = $class->SUPER::new( $parent, -1, $title );
    $self->SetIcon( Wx::GetWxPerlIcon() );
    $self->CreateStatusBar( 1 );
    $self->SetStatusWidths(2, 800, 100);
    Wx::InitAllImageHandlers();
    $self->{'title'} = $title;
    $self->{'config'} = App::GUI::Cellgraph::Config->new();
    my $sr_calc = App::GUI::Cellgraph::Compute::Subrule->new( 3, 2, 'all' );
    $self->{'img_size'} = 700;
    $self->{'img_format'} = 'png';
    my $window_size = [1200, 840];

lib/App/GUI/Cellgraph/Frame/Panel/Board.pm  view on Meta::CPAN


package App::GUI::Cellgraph::Frame::Panel::Board;
use base qw/Wx::Panel/;
use Benchmark;

use App::GUI::Cellgraph::Compute::Grid;
use Graphics::Toolkit::Color qw/color/;

sub new {
    my ( $class, $parent, $size ) = @_;
    my $self = $class->SUPER::new( $parent, -1, [-1,-1], [$size, $size] );
    $self->{'img_size'} = $size;
    $self->{'menu_size'} = 27;
    $self->{'size'}{'x'} = $size;
    $self->{'size'}{'y'} = $size;
    $self->{'dc'} = Wx::MemoryDC->new( );
    $self->{'bmp'} = Wx::Bitmap->new( $self->{'size'}{'x'} + 10, $self->{'size'}{'y'} +10 + $self->{'menu_size'}, 24);
    $self->{'dc'}->SelectObject( $self->{'bmp'} );

    Wx::Event::EVT_PAINT( $self, sub {
        my( $self, $event ) = @_;

lib/App/GUI/Cellgraph/Frame/Panel/ColorBrowser.pm  view on Meta::CPAN

use Graphics::Toolkit::Color qw/color/;

my $RGB = Graphics::Toolkit::Color::Space::Hub::get_space('RGB');
my $HSL = Graphics::Toolkit::Color::Space::Hub::get_space('HSL');

sub new {
    my ( $class, $parent, $type, $init_color ) = @_;
    $init_color = color( $init_color );
    return unless ref $init_color;

    my $self = $class->SUPER::new( $parent, -1);
    $self->{'init_color'} = $init_color->values( as => 'hash' );
    $self->{'call_back'} = sub {};

    my @rgb = $init_color->values('RGB');
    my @hsl = $init_color->values('HSL');

    $self->{'widget'}{'red'}   =  App::GUI::Cellgraph::Widget::SliderCombo->new( $self, 265, ' R  ', "red part of $type color",    0, 255,  $rgb[0]);
    $self->{'widget'}{'green'} =  App::GUI::Cellgraph::Widget::SliderCombo->new( $self, 265, ' G  ', "green part of $type color",  0, 255,  $rgb[1]);
    $self->{'widget'}{'blue'}  =  App::GUI::Cellgraph::Widget::SliderCombo->new( $self, 265, ' B  ', "blue part of $type color",   0, 255,  $rgb[2]);
    $self->{'widget'}{'hue'}   =  App::GUI::Cellgraph::Widget::SliderCombo->new( $self, 265, ' H  ', "hue of $type color",         0, 359,  $hsl[0]);

lib/App/GUI/Cellgraph/Frame/Panel/ColorPicker.pm  view on Meta::CPAN

use Wx;

package App::GUI::Cellgraph::Frame::Panel::ColorPicker;
use base qw/Wx::Panel/;
use App::GUI::Cellgraph::Widget::ColorDisplay;

sub new {
    my ( $class, $parent, $colors ) = @_;
    return unless ref $parent and ref  $colors eq 'HASH';

    my $self = $class->SUPER::new( $parent, -1 );

    $self->{'colors'} = { %$colors }; # $frame->{'config'}->get_value('color')
    $self->{'color_names'} = [ sort keys %{$self->{'colors'}} ];
    $self->{'color_index'} = 0;

    my $btnw = 46; my $btnh = 17;# button width and height
    $self->{'select'} = Wx::ComboBox->new( $self, -1, $self->current_color_name, [-1,-1], [170, -1], $self->{'color_names'});
    $self->{'<'}    = Wx::Button->new( $self, -1, '<',       [-1,-1], [ 30, 17] );
    $self->{'>'}    = Wx::Button->new( $self, -1, '>',       [-1,-1], [ 30, 17] );
    $self->{'load'} = Wx::Button->new( $self, -1, 'Load',    [-1,-1], [$btnw, $btnh] );

lib/App/GUI/Cellgraph/Frame/Panel/ColorSetPicker.pm  view on Meta::CPAN


use App::GUI::Cellgraph::Widget::ColorDisplay;
use Graphics::Toolkit::Color qw/color/;

our $default_color = {red => 225, green => 225, blue => 225};

sub new {
    my ( $class, $parent, $color_sets) = @_;
    return unless ref $parent and ref $color_sets eq 'HASH';

    my $self = $class->SUPER::new( $parent, -1 );

    $self->{'sets'} = { %$color_sets };
    $self->{'set_names'} = [ sort keys %{$self->{'sets'}} ];
    $self->{'set_index'} = 1;

    my $btnw = 46; my $btnh = 17;# button width and height
    $self->{'select'} = Wx::ComboBox->new( $self, -1, $self->current_set_name, [-1,-1], [170, -1], $self->{'set_names'});
    $self->{'<'}    = Wx::Button->new( $self, -1, '<',       [-1,-1], [ 27, $btnh] );
    $self->{'>'}    = Wx::Button->new( $self, -1, '>',       [-1,-1], [ 27, $btnh] );
    $self->{'load'} = Wx::Button->new( $self, -1, 'Load',    [-1,-1], [$btnw, $btnh] );

lib/App/GUI/Cellgraph/Frame/Tab/Action.pm  view on Meta::CPAN

use v5.12;
use warnings;
use Wx;
use base qw/Wx::Panel/;
use App::GUI::Cellgraph::Widget::RuleInput;
use App::GUI::Cellgraph::Widget::SliderCombo;
use Graphics::Toolkit::Color qw/color/;

sub new {
    my ( $class, $parent, $subrule_calculator ) = @_;
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'subrules'} = $subrule_calculator;
    $self->{'rule_square_size'} = 20;
    $self->{'input_size'} = 0;
    $self->{'state_count'} = 0;
    $self->{'rule_mode'} = '';
    $self->{'call_back'} = sub {};
    my $merge_condition = sub {
        my ($now, $last_time) = @_;
        return 0 unless ref $last_time eq 'ARRAY';

lib/App/GUI/Cellgraph/Frame/Tab/Color.pm  view on Meta::CPAN

use App::GUI::Cellgraph::Frame::Panel::ColorPicker;
use App::GUI::Cellgraph::Frame::Panel::ColorSetPicker;
use App::GUI::Cellgraph::Widget::ColorDisplay;
use App::GUI::Cellgraph::Widget::PositionMarker;
use Graphics::Toolkit::Color qw/color/;

our $default_color_def = $App::GUI::Cellgraph::Frame::Panel::ColorSetPicker::default_color;

sub new {
    my ( $class, $parent, $config ) = @_;
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'set_back'}  = sub {};
    $self->{'config'}     = $config;
    $self->{'rule_square_size'} = 34;
    $self->{'last_state'} = 8;   # max pos
    $self->{'state_count'} = 2;  # nr of currently used
    $self->{'current_state'} = 1;

    $self->{'state_colors'}       = [ color('white')->gradient( to => 'black', steps => $self->{'state_count'}) ];
    $self->{'state_colors'}[$_]   = color( $default_color_def ) for $self->{'state_count'} .. $self->{'last_state'};

lib/App/GUI/Cellgraph/Frame/Tab/General.pm  view on Meta::CPAN

use warnings;
use Wx;
use base qw/Wx::Panel/;
use App::GUI::Cellgraph::Compute::Subrule;

# action threshhold , value

sub new {
    my ( $class, $parent, $subrule_calc ) = @_;
    return unless ref $subrule_calc eq 'App::GUI::Cellgraph::Compute::Subrule';
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'subrules'} = $subrule_calc;
    $self->{'call_back'} = sub {};

    $self->create_label( 'logicals', 'State Rules', 'Section for rule logic settings' );
    $self->create_label( 'actions', 'Action Rules', 'Section for action rule logic settings' );
    $self->create_label( 'visuals',  'Visual Settings', 'Section for settings regarding appearances' );
    $self->create_label( 'input_size',  'Input Size :',  'Size of neighbourhood - from how many cells compute new cell state ?' );
    $self->create_label( 'state_count', 'Cell States :','How many states a cell can have ?' );
    $self->create_label( 'subrule_selection',   'Select :',   'Which selection of subrules are distinct? Rest gets bundled.' );

lib/App/GUI/Cellgraph/Frame/Tab/Rules.pm  view on Meta::CPAN

use warnings;
use Wx;
use base qw/Wx::Panel/;
use App::GUI::Cellgraph::Widget::RuleInput;
use App::GUI::Cellgraph::Widget::ColorToggle;
use App::GUI::Cellgraph::Compute::Rule;
use Graphics::Toolkit::Color qw/color/;

sub new {
    my ( $class, $parent, $subrule_calculator ) = @_;
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'subrules'} = $subrule_calculator;
    $self->{'rules'}    = App::GUI::Cellgraph::Compute::Rule->new( $subrule_calculator );
    $self->{'rule_square_size'} = 20;
    $self->{'input_size'} = 0;
    $self->{'state_count'} = 0;
    $self->{'rule_mode'} = '';
    $self->{'state_colors'} = [];
    $self->{'call_back'}  = sub {};
    App::GUI::Cellgraph::Compute::Grid::set_rules_tab( $self );

lib/App/GUI/Cellgraph/Frame/Tab/Start.pm  view on Meta::CPAN

package App::GUI::Cellgraph::Frame::Tab::Start;
use v5.12;
use warnings;
use Wx;
use base qw/Wx::Panel/;
use App::GUI::Cellgraph::Widget::ColorToggle;
use Graphics::Toolkit::Color qw/color/;

sub new {
    my ( $class, $parent ) = @_;
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'state_count'} = 2;
    $self->{'cells_in_row'} = my $cell_count = 20;
    $self->{'cells_iterator'} = [0 .. $cell_count - 1];
    $self->{'call_back'} = sub {};
    my $rule_cell_size = 20;

    $self->{'state_colors'}   = [map { [$_->values('rgb')]} color('white')->gradient_to('black', $self->{'state_count'})];
    $self->{'state_switches'} = [map { App::GUI::Cellgraph::Widget::ColorToggle->new
                                       ( $self, $rule_cell_size, $rule_cell_size, $self->{'state_colors'}, 0) } @{$self->{'cells_iterator'}}];

lib/App/GUI/Cellgraph/Widget/ColorDisplay.pm  view on Meta::CPAN

use warnings;
use Wx;

package App::GUI::Cellgraph::Widget::ColorDisplay;
use base qw/Wx::Panel/;

sub new {
    my ( $class, $parent, $x, $y, $nr, $init  ) = @_;
    return unless ref $init eq 'HASH' and exists $init->{'red'} and exists $init->{'green'}and exists $init->{'blue'};

    my $self = $class->SUPER::new( $parent, -1, [-1,-1], [$x, $y]);

    Wx::Event::EVT_PAINT( $self, sub {
        my( $cpanel, $event ) = @_;
        return unless exists $self->{'blue'} and exists $self->{'red'} and exists $self->{'green'};
        my $dc = Wx::PaintDC->new( $cpanel );
        my $bg_color = Wx::Colour->new( $self->{'red'}, $self->{'green'}, $self->{'blue'} );
        $dc->SetBackground( Wx::Brush->new( $bg_color, &Wx::wxBRUSHSTYLE_SOLID ) );
        $dc->Clear();
    } );
    $self->{'init'} = $init;

lib/App/GUI/Cellgraph/Widget/ColorToggle.pm  view on Meta::CPAN

use Wx;

package App::GUI::Cellgraph::Widget::ColorToggle;
use base qw/Wx::Panel/;

sub new {
    my ( $class, $parent, $x, $y, $colors, $start  ) = @_;
    return unless ref $colors eq 'ARRAY' and @$colors > 1;
    for (@$colors){ return unless ref $_ eq 'ARRAY' and @$_ == 3 }

    my $self = $class->SUPER::new( $parent, -1, [-1,-1], [$x+2, $y+2]);
    $self->{'colors'} = $colors;
    $self->{'callback'} = sub {};
    $self->{'init'} = $start // 0;
    $self->{'value'} = -1;
    $self->{'responsive'} = -1;

    Wx::Event::EVT_PAINT( $self, sub {
        my( $cpanel, $event ) = @_;
        my $dc = Wx::PaintDC->new( $cpanel );
        my $bg_color = Wx::Colour->new( @{$self->{'colors'}[ $self->{'value'} ]} );

lib/App/GUI/Cellgraph/Widget/PositionMarker.pm  view on Meta::CPAN

use warnings;
use Wx;

package App::GUI::Cellgraph::Widget::PositionMarker;
use base qw/Wx::Panel/;

sub new {
    my ( $class, $parent, $x, $y, $nr, $state, $color  ) = @_;
    return unless ref $color eq 'HASH' and exists $color->{'red'} and exists $color->{'green'}and exists $color->{'blue'};

    my $self = $class->SUPER::new( $parent, -1, [-1,-1], [$x, $y]);
    $self->{'nr'} = $nr;

    Wx::Event::EVT_PAINT( $self, sub {
        my( $cpanel, $event ) = @_;
        return unless exists $self->{'blue'} and exists $self->{'red'} and exists $self->{'green'};
        my $dc = Wx::PaintDC->new( $cpanel );
        my $bg_color = Wx::Colour->new( $self->{'red'}, $self->{'green'}, $self->{'blue'} );
        $dc->SetBackground( Wx::Brush->new( $bg_color, &Wx::wxBRUSHSTYLE_SOLID ) );
        $dc->Clear();
        my $black = Wx::Colour->new( 0, 0, 0 );

lib/App/GUI/Cellgraph/Widget/ProgressBar.pm  view on Meta::CPAN

use v5.12;
use warnings;
use Wx;

package App::GUI::Cellgraph::Widget::ProgressBar;
use base qw/Wx::Panel/;

sub new {
    my ( $class, $parent, $x, $y, @color  ) = @_;
    return unless @color > 1;
    my $self = $class->SUPER::new( $parent, -1, [-1,-1], [$x, $y]);
    $self->set_colors( @color );
    return unless ref $self->{'color'};

    $self->{'x'}     = $x;
    $self->{'y'}     = $y;
    $self->{'percentage'} = 100;

    Wx::Event::EVT_PAINT( $self, sub {
        my( $cpanel, $event ) = @_;
        my $dc = Wx::PaintDC->new( $cpanel );

lib/App/GUI/Cellgraph/Widget/RuleInput.pm  view on Meta::CPAN

    return unless ref $colors eq 'ARRAY' and defined $pattern;
    map { return unless ref $_ eq 'ARRAY' and @$_ == 3 } @$colors;

    $pattern = [split //, $pattern];
    my $ignore_center = !( @$pattern % 2);
    my $cell_count = @$pattern + $ignore_center;
    my $x = ($cell_size + 1) * $cell_count + 1;
    my $y = $cell_size + 2;
    my $half_count = int (@$pattern / 2);

    my $self = $class->SUPER::new( $parent, -1, [-1,-1], [$x, $y]);

    $self->{'pattern'} = $pattern;
    $self->{'colors'} = $colors;

    Wx::Event::EVT_PAINT( $self, sub {
        my( $cpanel, $event ) = @_;
        my $dc = Wx::PaintDC->new( $cpanel );
        my $bg_color = Wx::Colour->new( 255, 255, 255 );
        $dc->SetBackground( Wx::Brush->new( $bg_color, &Wx::wxBRUSHSTYLE_SOLID ) );
        $dc->Clear();

lib/App/GUI/Cellgraph/Widget/SliderCombo.pm  view on Meta::CPAN

package App::GUI::Cellgraph::Widget::SliderCombo;
use v5.12;
use warnings;
use Wx;
use base qw/Wx::Panel/;

sub new {
    my ( $class, $parent, $slider_size, $label, $help, $min, $max, $init_value, $delta, $value_name ) = @_;
    return unless defined $max;

    my $self = $class->SUPER::new( $parent, -1);
    my $lbl  = Wx::StaticText->new($self, -1, $label);
    $self->{'min_value'} = $min;
    $self->{'max_value'} = $max;
    $self->{'init_value'} = $init_value;
    $self->{'name'} = $label;
    $self->{'help'} = $help;
    $self->{'value'} = $init_value // $min;
    $self->{'value_delta'} = $delta // 1;
    $self->{'callback'} = sub {};
    return unless $self->{'value_delta'} != 0;



( run in 1.338 second using v1.01-cache-2.11-cpan-49f99fa48dc )