|
Porytiles
|
An 8x8 tile backed by mask-based storage that maps shape regions to pixel values. More...
#include <shape_tile.hpp>
Public Member Functions | |
| virtual | ~ShapeTile ()=default |
| ShapeTile ()=default | |
| auto | operator<=> (const ShapeTile &other) const =default |
| bool | is_transparent () const |
| Checks if this entire ShapeTile is transparent. | |
| ShapeTile | flip (bool h, bool v) const |
| Creates a flipped version of this ShapeTile. | |
| const std::map< ShapeMask, PixelType > & | colors () const |
| Returns the internal map of shape masks to pixel values. | |
| void | set (const ShapeMask &mask, const PixelType &color) |
| Sets or updates the pixel value for a specific shape mask. | |
Static Public Member Functions | |
| static bool | compare_shape_only (const ShapeTile &lhs, const ShapeTile &rhs) |
| Compares two ShapeTiles based ONLY on shape masks, ignoring pixel values. | |
An 8x8 tile backed by mask-based storage that maps shape regions to pixel values.
ShapeTile represents tiles as a collection of shape masks (ShapeMask) mapped to pixel values (PixelType). Unlike PixelTile which stores literal per-pixel data, ShapeTile stores tiles as a set of shape regions where each region is defined by a ShapeMask (which pixels are "on" in that region) and maps to a single pixel value.
This representation enables:
Multiple ShapeMask instances can be combined to define different color regions within a single tile. Each mask identifies which pixels belong to a particular region, and the associated PixelType provides the color or data for those pixels.
Key design features:
ShapeTile{} produces a transparent tile with an empty colors_ map, and an empty map is considered fully transparent by is_transparent().| PixelType | The pixel type stored for each shape region |
Definition at line 44 of file shape_tile.hpp.
|
virtualdefault |
|
default |
|
inline |
Returns the internal map of shape masks to pixel values.
Provides read-only access to the underlying std::map that stores the shape-to-pixel mappings. Each entry in the map represents a shape region (ShapeMask) and its associated pixel value (PixelType).
Definition at line 132 of file shape_tile.hpp.
|
inlinestatic |
Compares two ShapeTiles based ONLY on shape masks, ignoring pixel values.
This static method performs a lexicographic comparison of the shape masks (keys) only, completely ignoring the associated pixel values. This is a specialized comparison used for canonical orientation finding - tiles with identical shapes but different colors will compare based solely on their geometric structure.
This comparison is used to find the "minimal" or "canonical" orientation of a tile among its flipped variants, ensuring that tiles with the same shape structure but different color assignments can be identified as having equivalent geometry.
Note: This is different from operator< and operator<=>, which compare both shape masks AND pixel values.
Definition at line 70 of file shape_tile.hpp.
|
inline |
Creates a flipped version of this ShapeTile.
Returns a new ShapeTile with all shape masks flipped according to the specified parameters, while preserving the pixel value mappings. Horizontal flip reflects the tile across a vertical axis, vertical flip reflects across a horizontal axis.
Each ShapeMask in the tile is flipped individually using its flip() method, and the resulting flipped mask is mapped to the same pixel value as the original mask. This preserves the color assignments while transforming the tile's geometric structure.
If neither h nor v is true, returns a copy of the original tile.
| h | True to flip horizontally |
| v | True to flip vertically |
Definition at line 110 of file shape_tile.hpp.
|
inline |
Checks if this entire ShapeTile is transparent.
A ShapeTile is transparent if all of its shape masks are transparent (i.e., every ShapeMask has all bits unset). This check only examines the shape masks, not the pixel values associated with them.
Definition at line 86 of file shape_tile.hpp.
|
default |
|
inline |
Sets or updates the pixel value for a specific shape mask.
Associates the given pixel value with the specified shape mask. If the mask already exists in the tile, its pixel value is updated. If the mask does not exist, a new entry is created.
| mask | The shape mask identifying which pixels belong to this region |
| color | The pixel value to associate with this shape mask |
Definition at line 147 of file shape_tile.hpp.