App-traveller

 view release on metacpan or  search on metacpan

lib/Traveller/Mapper.pm  view on Meta::CPAN

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
}
.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 */
}
line.comm {
  stroke-width: 10pt;
  stroke: #ff6347; /* tomato */
}

lib/Traveller/Mapper.pm  view on Meta::CPAN

217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
                                   ($y - $x%2/2) * sqrt(3) * $scale);
                 $svg   .= sprintf(qq{    <text class="coordinates" x="%.3f" y="%.3f">}
                                 . qq{%02d%02d</text>\n},
                                   (1 + ($x-1) * 1.5) * $scale,
                                   ($y - $x%2/2) * sqrt(3) * $scale - 0.6 * $scale,
                                   $x, $y);
               } (0 .. $self->width * $self->height - 1));
  return $doc;
}
 
sub legend {
  my $self = shift;
  my $scale = 100;
  my $doc;
  my $uwp = '';
  if ($self->source) {
    $uwp = ' – <a xlink:href="' . $self->source . '">UWP</a>';
  }
  $doc .= sprintf(qq{    <text class="legend" x="%.3f" y="%.3f">â—‰ gas giant}
                  . qq{ – â–  Imperial consulate – ☼ TAS facility – â–² scout base}
                  . qq{ – ★ naval base – Ï€ research station – ☠ pirate base}
                  . qq{ – <tspan class="comm">â–®</tspan> communication}
                  . qq{ – <tspan class="trade">â–®</tspan> trade$uwp</text>\n},
                  -10, ($self->height + 1) * sqrt(3) * $scale);
  $doc .= sprintf(qq{    <text class="direction" x="%.3f" y="%.3f">coreward</text>\n},
                  $self->width/2 * 1.5 * $scale, -0.13 * $scale);
  $doc .= sprintf(qq{    <text transform="translate(%.3f,%.3f) rotate(90)"}
                  . qq{ class="direction">trailing</text>\n},
                  ($self->width + 0.4) * 1.5 * $scale, $self->height/2 * sqrt(3) * $scale);

lib/Traveller/Mapper.pm  view on Meta::CPAN

250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
                  -0.1 * $scale, $self->height/2 * sqrt(3) * $scale);
  return $doc;
}
 
sub footer {
  my $self = shift;
  my $doc;
  my $y = 10;
  my $debug = ''; # for developers
  for my $line (split(/\n/, $debug)) {
    $doc .= qq{<text xml:space="preserve" class="legend" y="$y" stroke="red">}
      . $line . qq{</text>\n};
    $y += 20;
  }
  $doc .= qq{</svg>\n};
  return $doc;
}
 
sub initialize {
  my ($self, $map, $wiki, $source) = @_;
  $self->source($source);

lib/Traveller/Mapper.pm  view on Meta::CPAN

563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
  foreach my $hex (@{$self->hexes}) {
    $data .= $hex->comm_svg();
  }
  $data .= qq{  </g>\n\n};
  $data .= qq{  <g id='routes'>\n};
  $data .= $self->trade_svg();
  $data .= qq{  </g>\n\n};
  $data .= qq{  <g id='grid'>\n};
  $data .= $self->grid;
  $data .= qq{  </g>\n\n};
  $data .= qq{  <g id='legend'>\n};
  $data .= $self->legend();
  $data .= qq{  </g>\n\n};
  $data .= qq{  <g id='system'>\n};
  foreach my $hex (@{$self->hexes}) {
    $data .= $hex->system_svg();
  }
  $data .= qq{  </g>\n};
  $data .= $self->footer();
  return $data;
}

lib/Traveller/Mapper/Classic.pm  view on Meta::CPAN

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
    my $d = @{$edge}[2];
    my ($x1, $y1) = ($u->x, $u->y);
    my ($x2, $y2) = ($v->x, $v->y);
    $data .= sprintf(qq{    <line class="trade d$d" x1="%.3f" y1="%.3f" x2="%.3f" y2="%.3f" />\n},
                     (1 + ($x1-1) * 1.5) * $scale, ($y1 - $x1%2/2) * sqrt(3) * $scale,
                     (1 + ($x2-1) * 1.5) * $scale, ($y2 - $x2%2/2) * sqrt(3) * $scale);
  }
  return $data;
}
 
sub legend {
  my $self = shift;
  my $scale = 100;
  my $doc;
  $doc .= sprintf(qq{    <text class="legend" x="%.3f" y="%.3f">â—‰ gas giant}
                  . qq{ – â–² scout base}
                  . qq{ – ★ navy base}
                  . qq{ – <tspan class="trade">â–®</tspan> trade},
                  -10, ($self->height + 1) * sqrt(3) * $scale);
  if ($self->source) {
    $doc .= ' – <a xlink:href="' . $self->source . '">UWP</a>';
  }
  $doc .= qq{</text>\n};
  $doc .= sprintf(qq{    <text class="direction" x="%.3f" y="%.3f">coreward</text>\n},
                  $self->width/2 * 1.5 * $scale, -0.13 * $scale);



( run in 0.255 second using v1.01-cache-2.11-cpan-4e96b696675 )