NAME
Game::TextMapper::Line - a line between two points
SYNOPSIS
use Modern::Perl;
use Game::TextMapper::Line::Hex;
use Game::TextMapper::Point::Hex;
my $line = Game::TextMapper::Line::Hex->new();
my $from = Game::TextMapper::Point::Hex->new(x => 1, y => 1, z => 0);
my $to = Game::TextMapper::Point::Hex->new(x => 5, y => 3, z => 0);
$line->points([$from, $to]);
my @line = $line->compute_missing_points;
say join(" ", map { $_->str } @line);
# (1,1,0) (2,1,0) (3,2,0) (4,2,0) (5,3,0)
DESCRIPTION
The line connects two points. This class knows how to compute all the regions between these two points, how to compute the next region along the line, and how to output SVG.
In order to do this, the class needs to know how to work with the regions on the map. This is different for hexes and squares. Therefore you should always be using the appropriate Hex or Square class instead.
ATTRIBUTES
points
An array reference of points using a class derived from Game::TextMapper::Point, i.e. Game::TextMapper::Line::Hex uses Game::TextMapper::Point::Hex and Game::TextMapper::Line::Square uses Game::TextMapper::Point::Square.
METHODS
compute_missing_points
Compute the missing points between the points in points
and return it.
svg($offset)
This returns an SVG fragment, a string with a path
.
svg_label
This returns an SVG fragment, a group g
with text
and a textPath
element.
SEE ALSO
Lines consist of Game::TextMapper::Point instances.
Use either Game::TextMapper::Line::Hex or Game::TextMapper::Line::Square to implement lines.