|
|
|
@ -12,11 +12,11 @@ use feature "signatures"; |
|
|
|
|
no warnings "experimental::signatures"; |
|
|
|
|
|
|
|
|
|
has tiles => (is => 'rw', default => sub { {} }); |
|
|
|
|
has subregions => (is => 'rw', default => sub { {} }); |
|
|
|
|
has name => (is => 'rw', required => 1); |
|
|
|
|
has defaults => (is => 'rw', default => sub { {} }); |
|
|
|
|
has id_suffix => (is => 'rw', default => '_region'); |
|
|
|
|
|
|
|
|
|
# New region with same properties, but doesn't import tiles |
|
|
|
|
sub clone($this) |
|
|
|
|
{ |
|
|
|
|
return HexGrid::Region->new |
|
|
|
@ -35,13 +35,6 @@ sub make_tile_at($this, $nw, $sw, %tile_settings) |
|
|
|
|
$this->add_tile(HexGrid::Tile::at($nw, $sw, %settings)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub add_subregion($this, $region) { $this->{subregions}{$region->{name}} = $region; } |
|
|
|
|
sub make_subregion($this, $name, %defaults) |
|
|
|
|
{ |
|
|
|
|
my $tile_defaults = merge(\%defaults, $this->{defaults}); |
|
|
|
|
$this->add_subregion(HexGrid::Region->new(name => $name, defaults => $tile_defaults)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub iter_tile($this, $code) |
|
|
|
|
{ |
|
|
|
|
foreach my $nw (keys %{$this->{tiles}}) |
|
|
|
@ -71,15 +64,6 @@ sub render($this, $svg, $laters, $grid) |
|
|
|
|
$max_y = $y_translate if $y_translate > $max_y; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
foreach my $region (keys %{$this->{subregions}}) |
|
|
|
|
{ |
|
|
|
|
my $m = $this->{subregions}{$region}->render($svg, $laters, $grid); |
|
|
|
|
|
|
|
|
|
$min_x = $m->{min_x} if $m->{min_x} < $min_x; |
|
|
|
|
$min_y = $m->{min_y} if $m->{min_y} < $min_y; |
|
|
|
|
$max_x = $m->{max_x} if $m->{max_x} > $max_x; |
|
|
|
|
$max_y = $m->{max_y} if $m->{max_y} > $max_y; |
|
|
|
|
} |
|
|
|
|
return { min_x => $min_x,min_y => $min_y,max_x => $max_x,max_y => $max_y, group => $g }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|