The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Game::TextMapper::Point - a point on the map

DESCRIPTION

This is a simple class to hold points. Points have coordinates and know how to print them.

Attributes

x, y, z are coordinates.

type, label, size are used to draw the SVG. These are used by the actual implementations, Game::TextMapper::Point::Hex and Game::TextMapper::Point::Square.

map is a reference to Game::TextMapper::Mapper from which to get text_attributes (for the coordinates), and both label_attributes and glow_attributes (for the label).

Methods

str

Returns "(1,2,3)" or "(1,2)" depending on whether the z coordinate is defined or not; use this for log output.

equal($other)

True if all three coordinates match.

cmp($other)

Return -1, 0, or 1 depending on the three coordinates.

coordinates

Return "1,1,1" or "1,1" for coordinates in scalar context, depending on whether the z coordinate is defined or not, or it returns the three coordinates in list context.

coord

Return "0101" or "-01-01" for coordinates. Often this what we want in text.

Abstract methods

These methods must be implemented by derived classes. The $offset argument is an array with the offsets to add to the y based on z coordinate. The idea is that if we have two dungeon levels, for example, and we want to generate a single SVG document, then the first level is at the top of the page, as usual, and the next level is further down on the page: all the y coordinates were increased by the offset.

svg_region($attributes, $offset)

This returns an SVG fragment, a string with a polygon or rect element, for example.

This is used for the group containing the regions in the resulting SVG.

svg($offset)

This returns an SVG fragment, a string with a use element.

This is used for the group containing the background colours in the resulting SVG.

svg_coordinates($offset)

This returns an SVG fragment, a string with a text element.

This is used for the group containing the coordinates in the resulting SVG.

svg_label($url, $offset)

This returns an SVG fragment, a string with a g element containing two text elements, and possibly an a element: the "glow", the label itself, and possibly a link to the URL.

This is used for g#labels (the group containing the labels) in the resulting SVG.

SEE ALSO

Game::TextMapper::Mapper uses this class. Internally, it calls make_region which is implemented by either Game::TextMapper::Mapper::Hex or Game::TextMapper::Mapper::Square. Depending on the implementation, Game::TextMapper::Point::Hex or Game::TextMapper::Point::Square are used to implement this class.