App-GUI-GoLP
view release on metacpan or search on metacpan
bin/golp
Changes
example/c5diagonalpuffer1.rle
example/owssagarstretcher.rle
example/POD/c5diagonalpuffer1.png
example/POD/owssagarstretcher.png
ignore.txt
lib/App/GUI/GoLP.pm
Makefile.PL
MANIFEST This list of files
README
README.md
t/00-load.t
t/manifest.t
t/pod-coverage.t
t/pod.t
Options
Play/Pause starts and pauses the simulation. This can also be done from the space bar.
Grid toggles the cell grid on and off.
Autogrow toggles the 'autogrow' on and off. When activated, the size of the board will be enlarged if there are live cells close to the edge of the board.
Status line toggles the status text which can be displayed along the bottom of the main window. This gives some information as to the current state of the simulation.
Snapshot board will create a .png image file of the board in the current working directory.
Loop delay presents a list of presets which affects the speed of the simulation.
Rules allows the user to select from a preset list of birth/survival rules, or use the Custom rule dialog to specify one.
Zoom opens the zoom dialog.
Live cell color allows the user to select the color of a 'live' cell.
Dead cell color allows the user to select the color of a 'dead' cell.
['*Grow' => '~Autogrow' => sub {
my ( $window, $menu ) = @_;
$autogrow = $window->menu->toggle($menu);
} ],
['*Status' => 'S~tatus line' => sub {
my ( $window, $menu ) = @_;
$status = $window->menu->toggle($menu);
$window->repaint();
} ],
[ '~Snapshot board' => 'F5' => kb::F5 => sub {
my $snapname = to_png($game->get_grid());
if ( -e $snapname ) {
message("Snapshot written to $snapname");
}
else {
message("ERROR - snapshot not created");
}
} ],
[ 'L~oop delay' => [
[ '(s_zero' => '0 ms' => sub { $_[0]->Timer->timeout(0); } ],
[ 'ms_25' => '25 ms' => sub { $_[0]->Timer->timeout(25); } ],
my $b_w = $board_width;
my $b_h = $board_height;
my $p_w = $b_w * $scale;
my $p_h = $b_h * $scale;
return render($cr, $data, $b_w, $b_h, $p_w, $p_h, $vp_w, $vp_h, $vp_x_offset, $vp_y_offset);
}
sub to_png {
my ($data) = @_;
my $b_w = $board_width;
my $b_h = $board_height;
my $p_w = $b_w * $scale;
my $p_h = $b_h * $scale;
my $surface = Cairo::ImageSurface->create('argb32', $p_w, $p_h);
my $cr = Cairo::Context->create($surface);
my $live_cells = render($cr, $data, $b_w, $b_h, $p_w, $p_h, $p_w, $p_h, 0, 0);
my $filename = "snapshot:" . $filebase . ";ticks:" . $ticks . ";livecells:" . $live_cells . ".png";
$cr->show_page;
$surface->write_to_png($filename);
return $filename;
}
# draw the board
sub render {
my ($cr, $data, $b_w, $b_h, $p_w, $p_h, $vp_w, $vp_h, $vp_x_o, $vp_y_o) = @_;
$cr->rectangle (0, 0, $vp_w, $vp_h);
$cr->set_source_rgb (0.1, 0.1, 0.1);
lib/App/GUI/GoLP.pm view on Meta::CPAN
=head1 SYNOPSIS
golp [<filename>]
=head1 DESCRIPTION
This program will load and run Life-like cellular automata from .rle or .cells files. A good source for files is L<https://conwaylife.com/wiki/Main_Page>. It uses L<Game::Life::Faster> for the engine and L<Prima> for the GUI.
=for HTML <p>
<img src="https://raw.githubusercontent.com/mjohnson108/p5-App-GUI-GoLP/main/example/POD/c5diagonalpuffer1.png" alt="" width="400" height="325">
<img src="https://raw.githubusercontent.com/mjohnson108/p5-App-GUI-GoLP/main/example/POD/owssagarstretcher.png" alt="" width="400" height="325">
</p>
=head2 Menus
=head3 File
The I<New> option allows the user to create a new board. Choose the width and height of the board and whether the initial cell status will be all 'dead', all 'live' or chosen at random according to a specified percentage chance. Use the I<Rules> subm...
The I<Open> option provides a dialog box allowing the user to select a .rle or .cells format file to be loaded.
lib/App/GUI/GoLP.pm view on Meta::CPAN
=head3 Options
I<Play/Pause> starts and pauses the simulation. This can also be done from the space bar.
I<Grid> toggles the cell grid on and off.
I<Autogrow> toggles the 'autogrow' on and off. When activated, the size of the board will be enlarged if there are live cells close to the edge of the board.
I<Status line> toggles the status text which can be displayed along the bottom of the main window. This gives some information as to the current state of the simulation.
I<Snapshot board> will create a .png image file of the board in the current working directory.
I<Loop delay> presents a list of presets which affects the speed of the simulation.
I<Rules> allows the user to select from a preset list of birth/survival rules, or use the I<Custom rule> dialog to specify one.
I<Zoom> opens the zoom dialog.
I<Live cell color> allows the user to select the color of a 'live' cell.
I<Dead cell color> allows the user to select the color of a 'dead' cell.
( run in 3.181 seconds using v1.01-cache-2.11-cpan-df04353d9ac )