App-GUI-Cellgraph

 view release on metacpan or  search on metacpan

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

              .  '  '.move_pattern_string('$left_pattern','$x_pos-1')
              .  '  '.move_pattern_string('$right_pattern','$x_pos+'.$input_overhang)
              .  '    $subrule_nr[$x_pos] = '.$eval_pattern.";\n  }\n"
              .  '  for my $x_pos ('.($compute_right_stop+1).' .. '.($grid_size - 1).'){'."\n"
              .  '  '.move_pattern_string('$left_pattern','$x_pos-1')
              .  '  '.move_pattern_string('$right_pattern', ($grid_circular ? '$x_pos+'.($input_overhang - $grid_size) : undef) )
              .  '    $subrule_nr[$x_pos] = '.$eval_pattern.";\n  }\n\n";
    }


    my $result = eval( $code . $code_end); # say $code . $code_end;
    say "compile in code:\n$code\n\n error: $@" if $@;
    # say "got grid in:",timestr( timediff(Benchmark->new, $t0) );
    $rules_tab->update_subrule_occurance( @subrule_occur );

    if ($sketch_length){
        $state_grid->[$_] = [@empty_row] for $compute_rows .. $grid_size - 1;
        return $state_grid;
    }
    return $state_grid if $grow_direction eq 'top_down';

    # implementing paint directions
    if ($grow_direction eq 'inside_out') {

lib/App/GUI/Cellgraph/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/Cellgraph/Frame/Panel/Board.pm  view on Meta::CPAN

                $dc->SetPen( $pen[$grid->[$y][$x]] );
                $dc->DrawLine( $x_cursor, $y_cursor, $x_cursor + $cl, $y_cursor);
                $dc->DrawLine( $x_cursor, $y_cursor + $cl, $x_cursor + $cl, $y_cursor + $cl);
                # $dc->DrawLine( $x_cursor, $y_cursor, $x_cursor, $y_cursor + $cl);
                # $dc->DrawLine( $x_cursor + $cl, $y_cursor, $x_cursor + $cl, $y_cursor + $cl);
                $x_cursor += $grid_d;
            }
            $y_cursor += $grid_d;
        }
    }
#say "paint took:",timestr( timediff(Benchmark->new, $t1) );
    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'" }

lib/App/GUI/Cellgraph/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 1.255 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )