Give tiles a style by default

main
Daniel Asher Resnick 5 months ago
parent 0e63a8d64f
commit 67bc6b64e8
  1. 5
      HexGrid/Tile.pm

@ -15,7 +15,7 @@ no warnings "experimental::signatures";
has nw => (is => 'ro', required => 1);
has sw => (is => 'ro', required => 1);
has style => (is => 'rw');
has style => (is => 'rw', default => sub { {} });
has colour => (is => 'rw', alias => 'color');
has opacity => (is => 'rw');
has images => (is => 'rw', alias => [qw(image background backgrounds)]);
@ -42,6 +42,7 @@ sub hex_path($w, $h)
{
# More readable for me at least as a sequence of points than as two sequences
my @points = ([0, $h/2], [$w*1/4, 0], [$w*3/4, 0], [$w, $h/2], [$w*3/4, $h], [$w*1/4, $h]);
# Join pairs with a comma, and sequence with spaces
return join " ", (map {join ",", @$_} @points);
}
@ -103,7 +104,7 @@ sub render($this, $container, $width, $height, $laters = undef)
);
# $g->{onclick} = "say('($this->{nw},$this->{sw})')";
my $hex = $g->polygon(points => hex_path($width, $height),
id => "$this->{nw}_$this->{sw}_inner_hex", style => $this->{style} || {});
id => "$this->{nw}_$this->{sw}_inner_hex", style => $this->style);
my $clipPath = $g->clipPath(id => "$this->{nw}_$this->{sw}_clip");
$clipPath->use(href => "#$hex->{id}");

Loading…
Cancel
Save