App-GUI-Harmonograph

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    field is naturally the directory where the files get saved. You can
    change it by pushing the *Dir* in front (left) of the text button and
    use the then opening Dir-Dialog to select another directory. The second
    text field holds the base file name, which has to be inserted by
    clicking on in and typing. The third text field is the file number and
    is readonly. That counter increments automatically when a file is
    generated. The complete file path is <dir>+<base
    name>+'_'+<counter>+<file ending>. The file ending is *.ini* for setting
    files and *.jpg* or *.png* or *.svg* for image files. The exact ending
    depends on what is the current configuration set in the image > format
    menu. Lets say your directory is "/home/user/images/h" and the base file
    name is beauty. If there is already a file
    "/home/user/images/h/beauty_4.png" - the program will detect that and
    set the counter to 5. You can play with the settings and than (no matter
    if there is currently a complete drawing or not) push the *Save* button
    to produce a complete drawing into "/home/user/images/h/beauty_5.png".
    If you push the *INI* button you safe the current settings into
    "/home/user/images/h/beauty_5.ini". This file can later be loaded via
    settings menu to restore the current state of all buttons in the tabs.

  Menu

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

The three text fields are combined the parts of the file path.
The first text field is naturally the directory where the files get saved.
You can change it by pushing the I<Dir> in front (left) of the text button
and use the then opening  Dir-Dialog to select another directory.
The second text field holds the base file name, which has to be inserted
by clicking on in and typing. The third text field is the file number and
is readonly. That counter increments automatically when a file is generated.
The complete file path is <dir>+<base name>+'_'+<counter>+<file ending>.
The file ending is I<.ini> for setting files and I<.jpg> or I<.png> or I<.svg>
for image files. The exact ending depends on what is the current configuration
set in the image > format menu. Lets say your directory is
"/home/user/images/h" and the base file name is beauty. If there is already
a file "/home/user/images/h/beauty_4.png" - the program will detect that
and set the counter to 5. You can play with the settings and than (no matter
if there is currently a complete drawing or not) push the I<Save> button
to produce a complete drawing into "/home/user/images/h/beauty_5.png".
If you push the I<INI> button you safe the current settings into
"/home/user/images/h/beauty_5.ini". This file can later be loaded via
settings menu to restore the current state of all buttons in the tabs.


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

    push @code, '  next if rand(1) > $pen_probability' if $pen_probability < 1;
    push @code, ($set->{'visual'}{'connect_dots'}
              ? ('  if ($line_broke) {$line_broke = 0; ($x_old, $y_old) = ($x, $y) }',
                 '  if ($x < 0 or $x > $board_size or $y < 0 or $y > $board_size) {$line_broke++; next}',
                '  $dc->DrawLine( $x_old, $y_old, $x, $y)',
                '  ($x_old, $y_old) = ($x, $y)' )
              : ($pen_size ? '  $dc->DrawCircle( $x, $y,$pen_size / 2 )' : '  $dc->DrawPoint( $x, $y )'));
    push @code, '}';
    push @code, '$progress_bar->add_percentage( 100, [$first_color->values] )' unless exists $args->{'sketch'} or $color_swap_time ;

    my $code = join '', map {$_.";\n"} @code, '}'; # say $code;
    my $code_ref = eval $code;
    die "bug '$@' in drawing code: $code" if $@;   # say "comp: ",timestr( timediff( Benchmark->new(), $t) );
say "draw";
    return $code_ref;
}


1;

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


sub save {
    my ($self) = @_;
    my $data = $self->{'data'};
    my $file = $self->{'path'};
    open my $FH, '>', $file or return "could not write $file: $!";
    $" = ',';
    for my $key (sort keys %$data){
        my $val = $data->{ $key };
        if (ref $val eq 'ARRAY'){
            say $FH "$key:";
            say $FH "  - $_" for @$val;
        } elsif (ref $val eq 'HASH'){
            say $FH "$key:";
            say $FH "  + $_ = [ @{$val->{$_}} ]" for sort keys %$val;
        } elsif (not ref $val){
            say $FH "$key = $val";
        }
    }
    close $FH;
}


sub get_value {
    my ($self, $key) = @_;
    $self->{'data'}{$key} if exists $self->{'data'}{$key};
}

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

    }
    close $FH;
    $data;
}

sub write {
    my ($file, $data) = @_;
    return unless ref $data eq 'HASH';
    open my $FH, '>', $file or return "could not write $file: $!";
    for my $main_key (sort keys %$data){
        say $FH "\n  [$main_key]\n";
        my $subhash = $data->{$main_key};
        next unless ref $subhash eq 'HASH';
        for my $key (sort keys %$subhash){
            say $FH "$key = $subhash->{$key}";
        }
    }
    close $FH;
    0;
}

sub ensure_file_ending {
    my ($file, $ending)  = @_;
    my $ret = $file;
    $ret;



( run in 3.457 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )