App-traveller
view release on metacpan or search on metacpan
lib/Traveller/Mapper.pm view on Meta::CPAN
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# Algorithms based on Traveller ©2008 Mongoose Publishing.
package Traveller::Mapper;
use List::Util qw(shuffle reduce);
use Mojo::Base -base;
use Traveller::Util qw(nearby distance in);
use Traveller::Hex;
has 'hexes' => sub { [] };
has 'routes' => sub { [] };
has 'comm_set';
has 'trade_set';
has 'source';
has 'width';
has 'height';
my $colour_re = qr/#([0-9a-f]{3}){1,2}/i;
my $example = q!Inedgeus 0101 D7A5579-8 G Fl Ni A
Geaan 0102 E66A999-7 G Hi Wa A
Orgemaso 0103 C555875-5 SG Ga Lt
Veesso 0105 C5A0369-8 G De Lo A
Ticezale 0106 B769799-7 T SG Ri A
Maatonte 0107 C6B3544-8 C G Fl Ni A
Diesra 0109 D510522-8 SG Ni
Esarra 0204 E869100-8 G Lo A
Rience 0205 C687267-8 G Ga Lo
Rearreso 0208 C655432-5 C G Ga Lt Ni
Laisbe 0210 E354663-3 Ag Lt Ni
Biveer 0302 C646576-9 C G Ag Ga Ni
Labeveri 0303 A796100-9 CT N G Ga Lo A
Sotexe 0408 E544778-3 G Ag Ga Lt A
Zamala 0409 A544658-13 T N G Ag Ga Ht Ni
Sogeeran 0502 A200443-14 CT N G Ht Ni Va
Aanbi 0503 E697102-7 G Ga Lo A
Bemaat 0504 C643384-9 C R G Lo Po
Diare 0505 A254430-11 TRN G Ni A
Esgeed 0507 A8B1579-11 RN G Fl Ni A
Leonbi 0510 B365789-9 T SG Ag Ri A
Reisbeon 0604 C561526-8 R G Ni
Atcevein 0605 A231313-11 CT G Lo Po
Usmabe 0607 A540A84-15 T G De Hi Ht In Po
Onbebior 0608 B220530-10 G De Ni Po A
Raraxema 0609 B421768-8 T NSG Na Po
Xeerri 0610 C210862-9 G Na
Onreon 0702 D8838A9-2 S Lt Ri A
Ismave 0703 E272654-4 Lt Ni
Lara 0704 C0008D9-5 SG As Lt Na Va A
Lalala 0705 C140473-9 R G De Ni Po
Maxereis 0707 A55A747-12 CT NSG Ht Wa
Requbire 0802 C9B4200-10 G Fl Lo A
Azaxe 0804 B6746B9-8 C G Ag Ga Ni A
Rieddige 0805 B355578-7 G Ag Ni A
Usorce 0806 E736110-3 G Lo Lt A
Solacexe 0810 D342635-4 P S Lt Ni Po R
!;
sub example {
return $example;
}
# The empty hex is centered around 0,0 and has a side length of 1,
# a maximum diameter of 2, and a minimum diameter of â3.
my @hex = ( -1, 0,
-0.5, sqrt(3)/2,
0.5, sqrt(3)/2,
1, 0,
0.5, -sqrt(3)/2,
-0.5, -sqrt(3)/2);
sub header {
my ($self, $width, $height) = @_;
# TO DO: support an option for North American âAâ paper dimensions (width 215.9 mm, length 279.4 mm)
$width //= 210;
$height //= 297;
my $template = <<EOT;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="${width}mm"
height="${height}mm"
viewBox="%s %s %s %s">
<desc>Traveller Subsector</desc>
<defs>
<style type="text/css"><![CDATA[
text {
font-size: 16pt;
font-family: Optima, "Optima Regular", Optima-Regular, Helvetica, sans-serif;
text-anchor: middle;
}
text a {
fill: blue;
text-decoration: underline;
}
.coordinates {
fill-opacity: 0.5;
}
.starport, .base {
font-size: 20pt;
}
.direction {
font-size: 24pt;
}
.legend {
text-anchor: start;
font-size: 14pt;
}
tspan.comm {
fill: #ff6347; /* tomato */
( run in 1.769 second using v1.01-cache-2.11-cpan-98e64b0badf )