From 07c1494b77d204164a1139026d9fd16a860befb8 Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Sat, 30 Dec 2023 12:44:09 -0600 Subject: [PATCH] Add configurable coordinate colours --- HexGrid/Tile.pm | 2 ++ wiki-map.pl | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/HexGrid/Tile.pm b/HexGrid/Tile.pm index 5533d72..b08f23e 100644 --- a/HexGrid/Tile.pm +++ b/HexGrid/Tile.pm @@ -20,6 +20,7 @@ has colour => (is => 'rw', alias => 'color'); has opacity => (is => 'rw'); has images => (is => 'rw', alias => [qw(image background backgrounds)]); has show_coords => (is => 'rw'); +has coords_colour => (is => 'rw', default => 'white'); has css_class => (is => 'rw'); has id_suffix => (is => 'rw', default => '_tile'); @@ -128,6 +129,7 @@ sub render($this, $container, $width, $height, $laters = undef) { my $text = $g->text(x => "@{[0.1 * $width]}", y => "@{[0.6 * $height]}", class => 'coords'); $text->{'font-size'} = '3em'; + $text->{fill} = $this->{coords_colour}; $text->cdata("$this->{nw},$this->{sw}"); } if(defined $this->{css_class}) { $g->{class} = $this->{css_class} } diff --git a/wiki-map.pl b/wiki-map.pl index 9c754b6..45c1744 100644 --- a/wiki-map.pl +++ b/wiki-map.pl @@ -89,6 +89,8 @@ foreach my $page (values %{$region_query_results->{query}{pages}}) next unless $parsed_template; say STDERR "Processing region: $page->{title}"; $region->{defaults}{colour} = $parsed_template->{named_params}{colour}; + $region->{defaults}{coords_colour} = $parsed_template->{named_params}{coordinates_colour} + if $parsed_template->{named_params}{coordinates_colour}; if($regiondir) { $regions_by_subregion{$region->{name}} = $region->{name}; @@ -120,6 +122,8 @@ foreach my $page (values %{$subregion_query_results->{query}{pages}}) say STDERR "Processing subregion: $page->{title}"; my $subregion = $grid->make_region($page->{title}); $subregion->{defaults}{colour} = $parsed_template->{named_params}{colour}; + $subregion->{defaults}{coords_colour} = $parsed_template->{named_params}{coordinates_colour} + if $parsed_template->{named_params}{coordinates_colour}; if($regiondir) { my $region_name = $parsed_template->{positional_params}[0]; @@ -155,6 +159,8 @@ foreach my $page (values %{$location_query_results->{query}{pages}}) my $location = $grid->make_region($page->{title}); $location->{defaults}{colour} = $parsed_template->{named_params}{colour}; + $location->{defaults}{coords_colour} = $parsed_template->{named_params}{coordinates_colour} + if $parsed_template->{named_params}{coordinates_colour}; push @{$background_pages{"File:$parsed_template->{named_params}{background}"}}, $location; my $region_name = $parsed_template->{positional_params}[1]; $regions_by_subregion{$location->{name}} = $region_name;