Porytiles
Loading...
Searching...
No Matches
porytiles::Metatile< PixelType > Class Template Reference

The core tileset entity - a 2x2 grid of PixelTile objects arranged into three layers. More...

#include <metatile.hpp>

Public Member Functions

 Metatile ()
 
bool operator== (const Metatile &) const =default
 
bool is_transparent () const
 Checks if this entire metatile is transparent (intrinsic transparency only).
 
bool is_transparent (const PixelType &extrinsic) const
 Checks if this entire metatile is transparent.
 
std::array< PixelTile< PixelType >, metatile::tiles_per_metatiledecompose () const
 Decomposes this metatile into an array of PixelTiles in metatile order.
 
LayerMode infer_layer_mode () const
 Infers the layer mode (dual or triple) based on metatile content (intrinsic transparency only).
 
LayerMode infer_layer_mode (const PixelType &extrinsic) const
 Infers the layer mode (dual or triple) based on metatile content.
 
LayerType infer_layer_type () const
 Infers the layer type based on which layers contain content (intrinsic transparency only).
 
LayerType infer_layer_type (const PixelType &extrinsic) const
 Infers the layer type based on which layers contain content.
 
const PixelTile< PixelType > & bottom (std::size_t i) const
 Get a constant reference to a PixelTile from the bottom layer.
 
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & bottom () const
 Get a constant reference to the entire bottom layer array.
 
void set_bottom (std::size_t i, PixelTile< PixelType > tile)
 Set a PixelTile in the bottom layer.
 
const PixelTile< PixelType > & middle (std::size_t i) const
 Get a constant reference to a PixelTile from the middle layer.
 
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & middle () const
 Get a constant reference to the entire middle layer array.
 
void set_middle (std::size_t i, PixelTile< PixelType > tile)
 Set a PixelTile in the middle layer.
 
const PixelTile< PixelType > & top (std::size_t i) const
 Get a constant reference to a PixelTile from the top layer.
 
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & top () const
 Get a constant reference to the entire top layer array.
 
void set_top (std::size_t i, PixelTile< PixelType > tile)
 Set a Tile in the top layer.
 

Detailed Description

template<SupportsTransparency PixelType>
class porytiles::Metatile< PixelType >

The core tileset entity - a 2x2 grid of PixelTile objects arranged into three layers.

Like its component PixelTile objects, the pixel type of Metatile is arbitrary.

Invariant
Default-constructed Metatile is transparent (satisfies SupportsTransparency design invariant). That is, Metatile<PixelType>{} produces a metatile where all PixelTile objects in all three layers are default-constructed (and thus transparent, assuming PixelTile and PixelType satisfy the invariant).
Template Parameters
PixelTypeThe pixel type of this Metatile's PixelTile objects

Definition at line 186 of file metatile.hpp.

Constructor & Destructor Documentation

◆ Metatile()

template<SupportsTransparency PixelType>
porytiles::Metatile< PixelType >::Metatile ( )
inline

Definition at line 188 of file metatile.hpp.

Member Function Documentation

◆ bottom() [1/2]

template<SupportsTransparency PixelType>
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & porytiles::Metatile< PixelType >::bottom ( ) const
inline

Get a constant reference to the entire bottom layer array.

Returns the complete array of tiles in the bottom layer, allowing for range-based iteration.

Returns
Constant reference to the bottom layer tile array.

Definition at line 352 of file metatile.hpp.

◆ bottom() [2/2]

template<SupportsTransparency PixelType>
const PixelTile< PixelType > & porytiles::Metatile< PixelType >::bottom ( std::size_t  i) const
inline

Get a constant reference to a PixelTile from the bottom layer.

Retrieves the PixelTile at the specified index in the bottom layer array.

Parameters
iThe index into the bottom layer array (must be 0-3).
Returns
Constant reference to the PixelTile at the specified index.

Definition at line 336 of file metatile.hpp.

◆ decompose()

template<SupportsTransparency PixelType>
std::array< PixelTile< PixelType >, metatile::tiles_per_metatile > porytiles::Metatile< PixelType >::decompose ( ) const
inline

Decomposes this metatile into an array of PixelTiles in metatile order.

Returns tiles in bottom-middle-top layer order, with each layer's tiles arranged sequentially.

Returns
An array containing the constituent tiles

Definition at line 243 of file metatile.hpp.

◆ infer_layer_mode() [1/2]

template<SupportsTransparency PixelType>
LayerMode porytiles::Metatile< PixelType >::infer_layer_mode ( ) const
inline

Infers the layer mode (dual or triple) based on metatile content (intrinsic transparency only).

A metatile uses triple-layer mode if all three layers contain at least one non-transparent pixel. Otherwise, it uses dual-layer mode. This overload uses intrinsic transparency checking.

Returns
LayerMode::triple if all layers have content, LayerMode::dual otherwise

Definition at line 264 of file metatile.hpp.

◆ infer_layer_mode() [2/2]

template<SupportsTransparency PixelType>
LayerMode porytiles::Metatile< PixelType >::infer_layer_mode ( const PixelType &  extrinsic) const
inline

Infers the layer mode (dual or triple) based on metatile content.

A metatile uses triple-layer mode if all three layers contain at least one non-transparent pixel. Otherwise, it uses dual-layer mode. This overload uses both intrinsic and extrinsic transparency checking.

Parameters
extrinsicThe extrinsic transparency value to check each pixel against
Returns
LayerMode::triple if all layers have content, LayerMode::dual otherwise

Definition at line 280 of file metatile.hpp.

◆ infer_layer_type() [1/2]

template<SupportsTransparency PixelType>
LayerType porytiles::Metatile< PixelType >::infer_layer_type ( ) const
inline

Infers the layer type based on which layers contain content (intrinsic transparency only).

Determines which layers (bottom, middle, top) are active for rendering based on content:

  • Triple-layer mode always returns LayerType::normal
  • For dual-layer mode, determines the layer type based on which layers have content:
    • Bottom only -> covered
    • Bottom + middle -> covered
    • Bottom + top -> split
    • All other combinations -> normal
Returns
The inferred LayerType

Definition at line 300 of file metatile.hpp.

◆ infer_layer_type() [2/2]

template<SupportsTransparency PixelType>
LayerType porytiles::Metatile< PixelType >::infer_layer_type ( const PixelType &  extrinsic) const
inline

Infers the layer type based on which layers contain content.

Determines which layers (bottom, middle, top) are active for rendering based on content:

  • Triple-layer mode always returns LayerType::normal
  • For dual-layer mode, determines the layer type based on which layers have content:
    • Bottom only -> covered
    • Bottom + middle -> covered
    • Bottom + top -> split
    • All other combinations -> normal
Parameters
extrinsicThe extrinsic transparency value to check each pixel against
Returns
The inferred LayerType

Definition at line 321 of file metatile.hpp.

◆ is_transparent() [1/2]

template<SupportsTransparency PixelType>
bool porytiles::Metatile< PixelType >::is_transparent ( ) const
inline

Checks if this entire metatile is transparent (intrinsic transparency only).

A metatile 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).

Returns
True if all tiles in all layers are transparent, false otherwise

Definition at line 201 of file metatile.hpp.

◆ is_transparent() [2/2]

template<SupportsTransparency PixelType>
bool porytiles::Metatile< PixelType >::is_transparent ( const PixelType &  extrinsic) const
inline

Checks if this entire metatile is transparent.

A metatile is transparent if all of its pixels are either intrinsically transparent or are extrinsically transparent, according to the provided extrinsic transparency value. This overload is only available for pixel types that support extrinsic transparency (e.g., Rgba32).

Parameters
extrinsicThe extrinsic transparency value to check each pixel against
Returns
True if all tiles in all layers are transparent, false otherwise

Definition at line 223 of file metatile.hpp.

◆ middle() [1/2]

template<SupportsTransparency PixelType>
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & porytiles::Metatile< PixelType >::middle ( ) const
inline

Get a constant reference to the entire middle layer array.

Returns the complete array of tiles in the middle layer, allowing for range-based iteration.

Returns
Constant reference to the middle layer tile array.

Definition at line 399 of file metatile.hpp.

◆ middle() [2/2]

template<SupportsTransparency PixelType>
const PixelTile< PixelType > & porytiles::Metatile< PixelType >::middle ( std::size_t  i) const
inline

Get a constant reference to a PixelTile from the middle layer.

Retrieves the PixelTile at the specified index in the middle layer array.

Parameters
iThe index into the middle layer array (must be 0-3).
Returns
Constant reference to the PixelTile at the specified index.

Definition at line 383 of file metatile.hpp.

◆ operator==()

template<SupportsTransparency PixelType>
bool porytiles::Metatile< PixelType >::operator== ( const Metatile< PixelType > &  ) const
default

◆ set_bottom()

template<SupportsTransparency PixelType>
void porytiles::Metatile< PixelType >::set_bottom ( std::size_t  i,
PixelTile< PixelType >  tile 
)
inline

Set a PixelTile in the bottom layer.

Moves the provided PixelTile into the specified index of the bottom layer array.

Parameters
iThe index into the bottom layer array (must be 0-3).
tileThe PixelTile to move into the array.

Definition at line 366 of file metatile.hpp.

◆ set_middle()

template<SupportsTransparency PixelType>
void porytiles::Metatile< PixelType >::set_middle ( std::size_t  i,
PixelTile< PixelType >  tile 
)
inline

Set a PixelTile in the middle layer.

Moves the provided PixelTile into the specified index of the middle layer array.

Parameters
iThe index into the middle layer array (must be 0-3).
tileThe PixelTile to move into the array.

Definition at line 413 of file metatile.hpp.

◆ set_top()

template<SupportsTransparency PixelType>
void porytiles::Metatile< PixelType >::set_top ( std::size_t  i,
PixelTile< PixelType >  tile 
)
inline

Set a Tile in the top layer.

Moves the provided PixelTile into the specified index of the top layer array.

Parameters
iThe index into the top layer array (must be 0-3).
tileThe PixelTile to move into the array.

Definition at line 460 of file metatile.hpp.

◆ top() [1/2]

template<SupportsTransparency PixelType>
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & porytiles::Metatile< PixelType >::top ( ) const
inline

Get a constant reference to the entire top layer array.

Returns the complete array of tiles in the top layer, allowing for range-based iteration.

Returns
Constant reference to the top layer tile array.

Definition at line 446 of file metatile.hpp.

◆ top() [2/2]

template<SupportsTransparency PixelType>
const PixelTile< PixelType > & porytiles::Metatile< PixelType >::top ( std::size_t  i) const
inline

Get a constant reference to a PixelTile from the top layer.

Retrieves the PixelTile at the specified index in the top layer array.

Parameters
iThe index into the top layer array (must be 0-3).
Returns
Constant reference to the Tile at the specified index.

Definition at line 430 of file metatile.hpp.


The documentation for this class was generated from the following file: