|
Porytiles
|
An 8x8 tile backed by literal-array-based per-pixel storage of an arbitrary pixel type. More...
#include <pixel_tile.hpp>
Public Member Functions | |
| virtual | ~PixelTile ()=default |
| PixelTile () | |
| PixelTile (std::array< PixelType, tile::size_pix > pix) | |
| 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. | |
| 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 |
An 8x8 tile backed by literal-array-based per-pixel storage of an arbitrary pixel type.
PixelTile represents tiles using direct per-pixel storage in a 64-element array (8x8 grid). Each pixel position in the tile explicitly stores a PixelType value, providing a straightforward one-to-one mapping between tile coordinates and pixel data. This contrasts with ShapeTile, which uses a mask-based representation that maps shape regions to pixel values.
This representation is ideal for:
The PixelType template parameter must satisfy the SupportsTransparency concept, meaning it must provide methods for checking whether a pixel is transparent. This enables transparency checking at both the intrinsic level (for pixel types like IndexPixel that have built-in transparency) and extrinsic level (for pixel types like Rgba32 where transparency is determined by comparison with a reference value).
Key features:
PixelTile<PixelType>{} produces a tile where all pixels are default-constructed (and thus transparent, assuming PixelType itself satisfies the invariant).| PixelType | The pixel type of this tile; must satisfy SupportsTransparency concept |
Definition at line 83 of file pixel_tile.hpp.
|
virtualdefault |
|
inline |
Definition at line 87 of file pixel_tile.hpp.
|
inlineexplicit |
Definition at line 89 of file pixel_tile.hpp.
|
inline |
Definition at line 181 of file pixel_tile.hpp.
|
inline |
Definition at line 189 of file pixel_tile.hpp.
|
inline |
Compares this PixelTile with another, treating all transparent pixels as equal.
This method provides a semantic equality comparison that differs from operator== in that it considers all transparent pixels to be equal, regardless of their underlying representation. Two pixels are considered equal if:
This is useful when comparing tiles where only the logical transparency state matters, not the specific pixel values. The practical application depends on the pixel type's transparency semantics. For IndexPixel, since only index 0 is intrinsically transparent, this method behaves like operator== in typical usage. However, for pixel types with more complex intrinsic transparency (e.g., hypothetical future types supporting multiple transparent representations), this method would treat all such representations as equal.
This overload is only available for pixel types that support intrinsic transparency (e.g., IndexPixel).
| other | The PixelTile to compare against |
Definition at line 146 of file pixel_tile.hpp.
|
inline |
Compares this PixelTile with another, treating all transparent pixels as equal.
This method provides a semantic equality comparison that differs from operator== in that it considers all transparent pixels to be equal, regardless of their underlying representation. Two pixels are considered equal if:
This is useful when comparing tiles where the specific representation of transparent pixels doesn't matter, only the logical transparency state. For example, a tile with Rgba32{255,0,255} (magenta, considered extrinsically transparent under default settings) and another with Rgba32{0,0,0,0} (black with alpha=0, also transparent) would be considered equal at those positions when using the appropriate extrinsic transparency value.
This overload is only available for pixel types that support extrinsic transparency (e.g., Rgba32).
| other | The PixelTile to compare against |
| extrinsic | The extrinsic transparency value to use when checking pixel transparency |
Definition at line 174 of file pixel_tile.hpp.
|
inline |
Creates a flipped copy of this PixelTile.
Returns a new PixelTile flipped according to the specified parameters. Horizontal flip reflects the tile across a vertical axis, vertical flip reflects across a horizontal axis.
| h_flip | Whether to flip horizontally |
| v_flip | Whether to flip vertically |
Definition at line 230 of file pixel_tile.hpp.
|
inline |
Checks if this entire PixelTile is transparent (intrinsic transparency only).
A PixelTile is transparent if all of its pixels are intrinsically transparent. This overload is only available for pixel types that support parameterless is_transparent() (e.g., IndexPixel).
Definition at line 102 of file pixel_tile.hpp.
|
inline |
Checks if this entire PixelTile is transparent.
A PixelTile is transparent if all of its pixels are either intrinsically or extrinsically transparent, according to the provided extrinsic transparency value. This overload is only available for pixel types that support extrinsic transparency (e.g., Rgba32).
| extrinsic | The extrinsic transparency value to check each pixel against |
Definition at line 119 of file pixel_tile.hpp.
|
default |
|
inline |
Definition at line 288 of file pixel_tile.hpp.
|
inline |
Definition at line 200 of file pixel_tile.hpp.
|
inline |
Definition at line 208 of file pixel_tile.hpp.
|
inline |
Returns the set of unique non-transparent colors present in this PixelTile (intrinsic transparency only).
This method constructs and returns a std::set containing all unique non-transparent PixelType values found in the tile. Pixels are filtered using their intrinsic transparency (via parameterless is_transparent()), and only non-transparent pixels are included in the result. The set automatically handles uniqueness, so duplicate pixel values will only appear once.
This overload is only available for pixel types that support intrinsic transparency (e.g., IndexPixel). For IndexPixel tiles, this means index 0 (intrinsically transparent) will be excluded from the returned set.
Definition at line 257 of file pixel_tile.hpp.
|
inline |
Returns the set of unique non-transparent colors present in this PixelTile.
This method constructs and returns a std::set containing all unique non-transparent PixelType values found in the tile. Pixels are filtered using both intrinsic and extrinsic transparency (via is_transparent(extrinsic)), and only non-transparent pixels are included in the result. The set automatically handles uniqueness, so duplicate pixel values will only appear once.
This overload is only available for pixel types that support extrinsic transparency (e.g., Rgba32). For Rgba32 tiles:
| extrinsic | The extrinsic transparency value to check each pixel against |
Definition at line 281 of file pixel_tile.hpp.