|
Porytiles
|
A PixelTile representation that stores the canonical (lexicographically minimal) orientation among all flipped variants. More...
#include <canonical_pixel_tile.hpp>
Public Member Functions | |
| CanonicalPixelTile (const PixelTile< PixelType > &tile) | |
| Constructs a CanonicalPixelTile by finding the canonical orientation of the input tile. | |
| CanonicalPixelTile (const PixelTile< PixelType > &tile, const PixelType &extrinsic_transparency) | |
| Canonicalizes the input tile's orientation under cross-ET strict weak ordering. | |
| auto | operator<=> (const CanonicalPixelTile &other) const =default |
| Three-way comparison operator that compares all fields in lexicographic order. | |
| bool | h_flip () const |
| Returns the horizontal flip flag. | |
| bool | v_flip () const |
| Returns the vertical flip flag. | |
Public Member Functions inherited from porytiles::PixelTile< PixelType > | |
| virtual | ~PixelTile ()=default |
| PixelTile () | |
| PixelTile (std::array< PixelType, tile::size_pix > pix) | |
| PixelTile (const PixelType &fill_value) | |
| Constructs a PixelTile with all pixels set to a fill value. | |
| auto | operator<=> (const PixelTile &) const =default |
| bool | is_transparent () const |
| Checks if this entire PixelTile is transparent (intrinsic transparency only). | |
| bool | is_transparent (const PixelType &extrinsic) const |
| Checks if this entire PixelTile is transparent. | |
| bool | equals_ignoring_transparency (const PixelTile &other) const |
| Compares this PixelTile with another, treating all transparent pixels as equal. | |
| bool | equals_ignoring_transparency (const PixelTile &other, const PixelType &extrinsic) const |
| Compares this PixelTile with another, treating all transparent pixels as equal. | |
| bool | equals_ignoring_transparency (const PixelTile &other, const PixelType &extrinsic, const PixelType &other_extrinsic) const |
| Compares this PixelTile with another, treating transparent pixels as equal, using independent extrinsic transparency values for each tile. | |
| PixelType | at (std::size_t i) const |
| PixelType | at (std::size_t row, std::size_t col) const |
| void | set (std::size_t i, const PixelType &p) |
| void | set (std::size_t row, std::size_t col, const PixelType &p) |
| PixelTile | flip (bool h_flip, bool v_flip) const |
| Creates a flipped copy of this PixelTile. | |
| std::set< PixelType > | unique_nontransparent_colors () const |
| Returns the set of unique non-transparent colors present in this PixelTile (intrinsic transparency only). | |
| std::set< PixelType > | unique_nontransparent_colors (const PixelType &extrinsic) const |
| Returns the set of unique non-transparent colors present in this PixelTile. | |
| const std::array< PixelType, tile::size_pix > & | pix () const |
Additional Inherited Members | |
Static Public Member Functions inherited from porytiles::PixelTile< PixelType > | |
| static std::weak_ordering | cross_et_compare (const PixelTile &a, const PixelType &a_et, const PixelTile &b, const PixelType &b_et) |
| Strict weak ordering that treats transparent pixels under each side's own ET as equivalent. | |
A PixelTile representation that stores the canonical (lexicographically minimal) orientation among all flipped variants.
CanonicalPixelTile 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 data 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.
This approach is particularly useful for:
| PixelType | The pixel type of this tile; must satisfy SupportsTransparency concept |
Definition at line 38 of file canonical_pixel_tile.hpp.
|
inlineexplicit |
Constructs a CanonicalPixelTile 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 PixelTile 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 the default PixelTile comparison operator (operator<=>), which compares pixel data element-by-element.
| tile | The input PixelTile to canonicalize |
Definition at line 59 of file canonical_pixel_tile.hpp.
|
inline |
Canonicalizes the input tile's orientation under cross-ET strict weak ordering.
Picks the lex-min orientation among the four flip combinations, using PixelTile<PixelType>::cross_et_compare with extrinsic_transparency supplied as both sides of the comparison. This produces an orientation that is stable across ET values: two tiles whose opaque-pixel patterns coincide but whose transparent pixels differ by ET will canonicalize to equivalent orientations (equivalent under cross_et_compare), which is the precondition for matching them in ET-aware lookup maps.
Only enabled for pixel types that support parameterized is_transparent (e.g., Rgba32). This constructor exists to support cross-tileset animation matching, where tiles compiled under different extrinsic transparency values must canonicalize to equivalent orientations so the matcher's cross-ET comparator finds them equal.
| tile | The input PixelTile to canonicalize. |
| extrinsic_transparency | The extrinsic transparency value to use for cross-ET comparison during canonicalization (applied to both sides, since we are comparing the tile's own flipped variants). |
Definition at line 110 of file canonical_pixel_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 CanonicalPixelTile's tile data will yield the original tile orientation.
Definition at line 164 of file canonical_pixel_tile.hpp.
|
default |
Three-way comparison operator that compares all fields in lexicographic order.
Provides complete ordering by comparing first the base PixelTile data, then h_flip_, then v_flip_. This enables CanonicalPixelTile instances to be used in ordered containers like std::set or std::map.
Two CanonicalPixelTile instances are equal if and only if they have identical canonical tile data and identical flip flags.
| other | The CanonicalPixelTile 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 CanonicalPixelTile's tile data will yield the original tile orientation.
Definition at line 178 of file canonical_pixel_tile.hpp.