App-GUI-Cellgraph
view release on metacpan or search on metacpan
lib/App/GUI/Cellgraph/Frame/Panel/Board.pm view on Meta::CPAN
$dc->DrawLine( 0, $grid_d * $_, $grid_max_x, $grid_d * $_) for 1 .. $self->{'cells'}{'y'};
}
my @color = map { Wx::Colour->new( $_->rgb ) } @{$self->{'state'}{'color'}{'objects'}};
my @pen = map {Wx::Pen->new( $_, 1, &Wx::wxPENSTYLE_SOLID )} @color;
my @brush = map { Wx::Brush->new( $_, &Wx::wxBRUSHSTYLE_SOLID ) } @color;
my $grid = App::GUI::Cellgraph::Compute::Grid::create( $self->{'state'}, $self->{'cells'}{'x'}, $sketch_length );
my $rows = $sketch_length ? ($sketch_length - 1) : ($self->{'cells'}{'x'} - 1);
my $cell_size_iterator = [0 .. $self->{'state'}{'global'}{'cell_size'}-1];
my $cl = $cell_size - 1;
my $y_cursor = 1;
#my $t1 = Benchmark->new;
if ($self->{'state'}{'global'}{'fill_cells'}){
for my $y (0 .. $rows) {
my $x_cursor = 1;
for my $x (0 .. $self->{'cells'}{'x'}-1) {
$dc->SetPen( $pen[$grid->[$y][$x] // 0] );
$dc->DrawLine( $x_cursor, $y_cursor+$_, $x_cursor + $cl, $y_cursor+$_) for @$cell_size_iterator;
#$dc->SetBrush( $brush[$grid->[$y][$x]] );
#$dc->DrawRectangle( $x_cursor, $y_cursor, $cell_size, $cell_size );
$x_cursor += $grid_d;
}
$y_cursor += $grid_d;
}
} else {
for my $y (0 .. $rows) {
my $x_cursor = 1;
for my $x (0 .. $self->{'cells'}{'x'}-1) {
$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 );
( run in 0.224 second using v1.01-cache-2.11-cpan-4d50c553e7e )