You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
wiki-map/tests/paths.pl

48 lines
1.3 KiB

use v5.36;
use rlib '..';
use HexGrid;
use HexGrid::Path;
use Carp;
use Data::Dumper;
my $MAP_SIZE = 3;
my $grid = HexGrid->new(defaults => {
style => { 'stroke-width' => 1, stroke => 'white' },
show_coords => 0});
my $region = $grid->make_region("TEST");
for (my $nw=-$MAP_SIZE; $nw <= $MAP_SIZE; $nw++)
{
for (my $sw=-$MAP_SIZE; $sw <= $MAP_SIZE; $sw++)
{
$region->make_tile_at($nw, $sw);
}
}
$grid->make_path_from('test-id',
[[0,0], [1,0], [1,1], [2,0], [2,-1], [2,-2], [1,-2], [1,-1], [2,-1], [3,-1]],
colour => 'lime', css_class => 'path', style => { 'stroke-width' => 5 }
);
$grid->make_path_from('point-id', [[-1,1]],
colour => 'cyan', css_class => 'path', style => { 'stroke-width' => 5 }
);
$grid->make_path_from('loop-id',
[[-2,0], [-1,0], [-1,-1], [-2,-1], [-2,0]],
colour => 'red', css_class => 'path', style => { 'stroke-width' => 5 }
);
# say "@{[$grid->coords_of_centre(-2,0)]}";
# say "@{[$grid->coords_of_edge(-2,0,$HexGrid::DIR{nw})]}";
# say "@{[$grid->coords_of_edge(-2,0,$HexGrid::DIR{sw})]}";
# say "@{[$grid->coords_of_edge(-2,0,$HexGrid::DIR{s})]}" ;
# say "@{[$grid->coords_of_edge(-2,0,$HexGrid::DIR{se})]}";
# say "@{[$grid->coords_of_edge(-2,0,$HexGrid::DIR{ne})]}";
# say "@{[$grid->coords_of_edge(-2,0,$HexGrid::DIR{n})]}" ;
# say Dumper($grid);
say $grid->render;