|
Porytiles
|
A ShapeTile representation that stores the canonical (lexicographically minimal) orientation among all flipped variants. More...
#include <canonical_shape_tile.hpp>
Public Member Functions | |
| CanonicalShapeTile (const ShapeTile< PixelType > &tile) | |
| Constructs a CanonicalShapeTile by finding the canonical orientation of the input tile. | |
| auto | operator<=> (const CanonicalShapeTile &other) const =default |
| Three-way comparison operator that compares all fields. | |
| bool | h_flip () const |
| Returns the horizontal flip flag. | |
| bool | v_flip () const |
| Returns the vertical flip flag. | |
Public Member Functions inherited from porytiles2::ShapeTile< PixelType > | |
| 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. | |
Additional Inherited Members | |
Static Public Member Functions inherited from porytiles2::ShapeTile< PixelType > | |
| static bool | compare_shape_only (const ShapeTile &lhs, const ShapeTile &rhs) |
| Compares two ShapeTiles based ONLY on shape masks, ignoring pixel values. | |
A ShapeTile representation that stores the canonical (lexicographically minimal) orientation among all flipped variants.
CanonicalShapeTile finds and stores the canonical orientation of a tile by evaluating all four possible flip combinations (no flip, horizontal only, vertical only, and both horizontal and vertical). The canonical orientation is defined as the lexicographically minimal tile shape among these four variants.
This representation enables:
The stored flip flags (h_flip_ and v_flip_) represent the transformation needed to convert the canonical tile back to the original input tile. For example, if the input tile's horizontal flip is its canonical form, h_flip() will return true, indicating that horizontally flipping the canonical tile reproduces the original.
Key difference from CanonicalPixelTile:
This approach is particularly useful for:
| PixelType | The pixel type stored for each shape region |
Definition at line 44 of file canonical_shape_tile.hpp.
|
inlineexplicit |
Constructs a CanonicalShapeTile by finding the canonical orientation of the input tile.
This constructor evaluates all four possible flip combinations of the input tile:
The lexicographically minimal tile among these four variants is selected as the canonical form and stored as the base ShapeTile data. The flip flags that transform this canonical form back to the input tile are stored in h_flip_ and v_flip_.
The lexicographic comparison is performed using ShapeTile::compare_shape_only, which compares ONLY the shape masks (geometry) and ignores pixel values. This means two tiles with identical shapes but different color assignments will canonicalize to the same shape structure (though their pixel values will differ).
| tile | The input ShapeTile to canonicalize |
Definition at line 66 of file canonical_shape_tile.hpp.
|
inline |
Returns the horizontal flip flag.
Indicates whether the canonical tile must be horizontally flipped to reproduce the original input tile. If true, applying a horizontal flip to this CanonicalShapeTile's tile data will yield the original tile orientation.
Definition at line 125 of file canonical_shape_tile.hpp.
|
default |
Three-way comparison operator that compares all fields.
Performs member-wise comparison in declaration order:
This operator is consistent with operator==, ensuring that:
| other | The CanonicalShapeTile to compare against |
|
inline |
Returns the vertical flip flag.
Indicates whether the canonical tile must be vertically flipped to reproduce the original input tile. If true, applying a vertical flip to this CanonicalShapeTile's tile data will yield the original tile orientation.
Definition at line 139 of file canonical_shape_tile.hpp.