App-GUI-Harmonograph

 view release on metacpan or  search on metacpan

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

use v5.12;
use warnings;
use Wx;

package App::GUI::Harmonograph::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::Harmonograph' );

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

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

use App::GUI::Harmonograph::Frame::Panel::Pendulum;
use App::GUI::Harmonograph::Frame::Tab::Function;
use App::GUI::Harmonograph::Frame::Tab::Visual;
use App::GUI::Harmonograph::Frame::Tab::Color;
use App::GUI::Harmonograph::Widget::ProgressBar;
use App::GUI::Harmonograph::Settings; # file IO for parameters of image
use App::GUI::Harmonograph::Config;   # file IO for program config: dirs, color set store

sub new {
    my ( $class, $parent, $title ) = @_;
    my $self = $class->SUPER::new( $parent, -1, $title );
    $self->SetIcon( Wx::GetWxPerlIcon() ); # !!! better icon
    $self->{'title'} = $title;
    $self->{'config'} = App::GUI::Harmonograph::Config->new();
    Wx::ToolTip::Enable( $self->{'config'}->get_value('tips') );
    Wx::InitAllImageHandlers();
    $self->CreateStatusBar( 2 );
    $self->SetStatusWidths( 620, -1);
    $self->SetStatusText( "no file loaded", 1 );

    # create GUI parts

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

use utf8;
use Wx;
use base qw/Wx::Panel/;
use Graphics::Toolkit::Color qw/color/; #
use App::GUI::Harmonograph::Compute::Drawing;

my $TAU = 6.283185307;

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

lib/App/GUI/Harmonograph/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::Harmonograph::Widget::SliderCombo->new( $self, 365, ' R  ', "red part of $type color",    0, 255,  $rgb[0]);
    $self->{'widget'}{'green'} =  App::GUI::Harmonograph::Widget::SliderCombo->new( $self, 365, ' G  ', "green part of $type color",  0, 255,  $rgb[1]);
    $self->{'widget'}{'blue'}  =  App::GUI::Harmonograph::Widget::SliderCombo->new( $self, 365, ' B  ', "blue part of $type color",   0, 255,  $rgb[2]);
    $self->{'widget'}{'hue'}   =  App::GUI::Harmonograph::Widget::SliderCombo->new( $self, 365, ' H  ', "hue of $type color",         0, 359,  $hsl[0]);

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

use Wx;

package App::GUI::Harmonograph::Frame::Panel::ColorPicker;
use base qw/Wx::Panel/;
use App::GUI::Harmonograph::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/Harmonograph/Frame/Panel/ColorSetPicker.pm  view on Meta::CPAN


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

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

sub new {
    my ( $class, $parent, $color_sets, $max_display_count ) = @_;
    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;
    $self->{'max_display_count'} = $max_display_count;

    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] );

lib/App/GUI/Harmonograph/Frame/Panel/Pendulum.pm  view on Meta::CPAN

my %const = (1 => 1, 2 => 2, 3 => 3, '√2' => 1.4142135623731, '√3' => 1.73205080756888, '√5' => 2.236067977499789,
            'Ï€' => 3.1415926535,  'Ï„' => 6.2831853071795,
            'φ' => 0.61803398874989, 'Φ' => 1.61803398874989,
              e => 2.718281828,  'γ' => 0.57721566490153286, 'Γ' => 1.7724538509055160,
              G => 0.9159655941772190150, A => 1.28242712910062,
);

sub new {
    my ( $class, $parent, $label, $help, $on, $max ) = @_;
    return unless defined $max;
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'name'} = $label;
    $self->{'maxf'} = $max;
    $self->{'initially_on'} = $on;
    $self->{'callback'} = sub {};

    $self->{'on'} = Wx::CheckBox->new( $self, -1, '', [-1,-1], [-1,-1], $on );
    $self->{'on'}->SetToolTip("set partial $help on or off");

    my $main_label  = Wx::StaticText->new($self, -1, uc($label) );

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

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

our $default_color_def = $App::GUI::Harmonograph::Frame::Panel::ColorSetPicker::default_color;
my $default_settings = { 1=> 'blue', 2=> 'red', dynamic => 0, delta_S => 0, delta_L => 0 };

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

    $self->{'call_back'}  = sub {};
    $self->{'config'}     = $config;
    $self->{'color_count'} = 10;        # number of displayed colors
    $self->{'active_color_count'} = 2;  # nr of currently used colors, overwritten on init
    $self->{'current_color_nr'} = 0;    # index starts from 0
    $self->{'display_size'} = 33;

    $self->{'used_colors'}       = [ color('blue')->gradient( to => 'red', steps => $self->{'active_color_count'}) ];
    $self->{'used_colors'}[$_]   = color( $default_color_def ) for $self->{'active_color_count'} .. $self->{'color_count'}-1;

lib/App/GUI/Harmonograph/Frame/Tab/Function.pm  view on Meta::CPAN

    r11_function => 'cos', r11_operator => '=', r11_factor => '1', r11_variable => 'R time',
    r12_function => 'sin', r12_operator => '=', r12_factor => '1', r12_variable => 'R time',
    r21_function => 'sin', r21_operator => '=', r21_factor => '1', r21_variable => 'R time',
    r22_function => 'cos', r22_operator => '=', r22_factor => '1', r22_variable => 'R time',
    first_rotary => 'r'
};

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

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

    $self->{$_.'_function'} = Wx::ComboBox->new( $self, -1, '', [-1,-1], [ 82, -1], [@function_names], &Wx::wxTE_READONLY) for @pendulum_names;
    $self->{$_.'_operator'} = Wx::ComboBox->new( $self, -1, '', [-1,-1], [ 65, -1], [@operator_names], &Wx::wxTE_READONLY) for @pendulum_names;
    $self->{$_.'_factor'}   = Wx::ComboBox->new( $self, -1,  1, [-1,-1], [ 75, -1], [-1,1..17]       , &Wx::wxTE_READONLY) for @pendulum_names;
    $self->{$_.'_constant'} = Wx::ComboBox->new( $self, -1,  1, [-1,-1], [ 75, -1], [@const_names]   , &Wx::wxTE_READONLY) for @pendulum_names;
    $self->{$_.'_variable'} = Wx::ComboBox->new( $self, -1, '', [-1,-1], [105, -1], [@variable_names], &Wx::wxTE_READONLY) for @pendulum_names;
    $self->{'order'} = Wx::RadioBox->new( $self, -1, 'Order of Rotary Pendula', [-1, -1], [165, -1], [' R > W ', ' W > R ']);
    $self->{'order'}->SetToolTip('apply which pendulum first ?');


lib/App/GUI/Harmonograph/Frame/Tab/Visual.pm  view on Meta::CPAN

        duration=> 60, dot_density => 200, colors_used => 2,
        color_flow_type => 'no', color_flow_dynamic => 0, color_flow_speed => 4, invert_flow_speed => 0,
};
my @state_keys = keys %$default_settings;
my @state_widgets = qw/line_thickness pen_style dot_probability color_flow_type
                       color_flow_dynamic color_flow_speed invert_flow_speed colors_used/;
my @widget_keys;

sub new {
    my ($class, $parent, $color_tab) = @_;
    my $self = $class->SUPER::new( $parent, -1 );
    return unless ref $color_tab eq 'App::GUI::Harmonograph::Frame::Tab::Color';
    $self->{'callback'} = sub {};

    $self->{'label'}{'line'}   = Wx::StaticText->new($self, -1, 'Pen Settings' );
    $self->{'label'}{'time'}   = Wx::StaticText->new($self, -1, 'Drawing Duration (Line Length)' );
    $self->{'label'}{'dense'}  = Wx::StaticText->new($self, -1, 'Dot Density' );
    $self->{'label'}{'random'}  = Wx::StaticText->new($self, -1, 'Dot Randomisation' );
    $self->{'label'}{'flow'}   = Wx::StaticText->new($self, -1, 'Color Change' );
    $self->{'label'}{'flow_type'} = Wx::StaticText->new( $self, -1, 'Change Type:');
    $self->{'label'}{'colors'} = Wx::StaticText->new( $self, -1, 'Colors:');

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

use warnings;
use Wx;

package App::GUI::Harmonograph::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/Harmonograph/Widget/PositionMarker.pm  view on Meta::CPAN

use warnings;
use Wx;

package App::GUI::Harmonograph::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/Harmonograph/Widget/ProgressBar.pm  view on Meta::CPAN

use warnings;
use Wx;

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

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

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

    $self->{'x'}     = $x;
    $self->{'y'}     = $y;
    $self->{'color'} = $color;
    $self->{'percentage'} = [];

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

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

package App::GUI::Harmonograph::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.305 second using v1.01-cache-2.11-cpan-49f99fa48dc )