use v5.30; use HexGrid; use HexGrid::Pin; use Data::Dumper; use Text::Lorem; my $lorem = Text::Lorem->new; # my $adder_pin = new HexGrid::Pin(id => 'mountain-pin', icon => 'mountain.svg', name => 'Adder', description => $lorem->sentences(1)); my $grid = HexGrid->new(defaults => { style => { 'stroke-width' => 1, 'stroke' => 'black' }, show_coords => 1 }); $grid->make_region("Viper's Gate", colour => 'red'); # $grid->make_region('Adderwall', colour => 'orange', pins => {n => $adder_pin}); my $adderwall = $grid->make_region('Adderwall', colour => 'orange'); # $adderwall->make_subregion('Adderwall foothills', colour => 'moccasin'); $grid->make_region('Adderwall foothills', colour => 'moccasin'); $grid->make_region('Midhills', colour => 'moccasin'); # $grid->make_region('Minev', colour => 'green', images => ["forest-tile.png"]); $grid->make_region('Minev', colour => 'green'); $grid->make_region('Barrowcross', colour => 'darkgreen'); $grid->make_region('Shinei Mavet', colour => 'orange'); $grid->make_region('Jagged Shinei Mavet', colour => 'orange'); $grid->make_region('Shinei Mavet waters', colour => 'lightcyan'); # $grid->make_region('Shinei Mavet', colour => 'orange', image => 'mountain.svg'); # $grid->make_region('Jagged Shinei Mavet', colour => 'orange', images => ['mountain.svg', 'jagged.svg']); # $grid->make_region('Shinei Mavet waters', colour => 'lightcyan', image => 'foo.png'); $grid->make_region('Southern Ocean', colour => 'skyblue'); $grid->make_region('A volcano', colour => 'orange'); $grid->make_region('Buslish Scrubs', colour => 'beige'); $grid->make_region('The Blasted Metropolis', colour => 'gray'); $grid->make_region('The sprawling grasses', colour => 'beige'); $grid->make_region('Something sandy?', colour => 'navajowhite'); $grid->make_region('Necromancer', colour => 'orange'); $grid->make_region('The Narrow Sea', colour => 'skyblue'); $grid->make_region('Naurardhon', colour => 'palegoldenrod'); $grid->make_region('The Glades of Leamingbury', colour => 'lightgreen'); $grid->make_region('Cape of Lost Causes', colour => 'gray'); $grid->make_region('Deadlands', colour => 'black'); $grid->make_region('Deadlands', colour => 'black'); $grid->make_region('Glade borders', colour => 'mediumaquamarine'); $grid->make_region('Thicket', colour => 'darkgreen'); $grid->make_region('Random house', colour => 'darkgreen'); $grid->make_region('Abbey of Plendor', colour => 'beige'); $grid->make_region('Khulanu', opacity => '0', style => { 'stroke-width' => 5, 'stroke' => 'black' }); my $tiles; open $tiles, "$ENV{HOME}/RPG-stuff/WestOfVipers/coordinate-mapping"; my $region = <$tiles>; chomp($region); while(my $coords = <$tiles>) { if ($coords =~ /^\s*$/) { $region = <$tiles>; chomp($region); next; } chomp $coords; my %settings; if($coords =~ /:$/) { for(my $line = <$tiles>; $line !~ /^;/; $line = <$tiles>) { my($key, $val) = split /:/, $line; $settings{$key} = $val; } chop($coords); } my ($nw,$sw) = split /,/, $coords; my $tile = $grid->{regions}{$region}->make_tile_at($nw, $sw, %settings); if($region eq "Necromancer") { $tile->pin(new HexGrid::Pin(id => "circle-pin", icon => "foo2.svg", name => "zap", description => scalar $lorem->paragraphs(4), href => 'http://www.tensor.green')); } } close $tiles; # $grid->get_tile_at(0,0)->pin( # $grid->{regions}{"Viper's Gate"}{tiles}{0}{0}->pin( # { # 'n' => new HexGrid::Pin(icon => "1"), # 'se' => new HexGrid::Pin(icon => "2"), # 'sw' => new HexGrid::Pin(icon => "3") # } # ); # $grid->get_tile_at(0,0)->pin( # new HexGrid::Pin(icon => "foo2.svg"), # 'se' # ); # $grid->get_tile_at(0,0)->pin( # new HexGrid::Pin(icon => "mountain.svg") # ); # $grid->get_tile_at(0,0)->pin( # new HexGrid::Pin(icon => "foo2.svg") # ); # $grid->{regions}{"Viper's Gate"}{tiles}{0}{0}->pin( # new HexGrid::Pin(icon => "2") # ); # $grid->{regions}{"Viper's Gate"}{tiles}{0}{0}->pin( # new HexGrid::Pin(icon => "3"), # 'sw' # ); say ""; say "\n"; say < function clickPin(pinId, containerId) { let popup = document.getElementById(pinId + '-popup'); popup.style.visibility = popup.style.visibility == 'visible' ? 'hidden' : 'visible'; } EOS say $grid->render; # $grid->render; say "\n"; sub random_colour { my $str = '#'; $str .= sprintf('%02X', int(rand(256))) for 1..3; return $str; }