Game::TextMapper::Line - a line between two points
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)
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.
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.
Compute the missing points between the points in points and return it.
points
This returns an SVG fragment, a string with a path.
path
This returns an SVG fragment, a group g with text and a textPath element.
g
text
textPath
Lines consist of Game::TextMapper::Point instances.
Use either Game::TextMapper::Line::Hex or Game::TextMapper::Line::Square to implement lines.
To install Game::TextMapper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::TextMapper
CPAN shell
perl -MCPAN -e shell install Game::TextMapper
For more information on module installation, please visit the detailed CPAN module installation guide.