Porytiles
Loading...
Searching...
No Matches
porytiles2::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.
 
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 porytiles2::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 95 of file metatile.hpp.

Constructor & Destructor Documentation

◆ Metatile()

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

Definition at line 97 of file metatile.hpp.

Member Function Documentation

◆ bottom() [1/2]

template<SupportsTransparency PixelType>
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & porytiles2::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 189 of file metatile.hpp.

◆ bottom() [2/2]

template<SupportsTransparency PixelType>
const PixelTile< PixelType > & porytiles2::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 173 of file metatile.hpp.

◆ decompose()

template<SupportsTransparency PixelType>
std::array< PixelTile< PixelType >, metatile::tiles_per_metatile > porytiles2::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 152 of file metatile.hpp.

◆ is_transparent() [1/2]

template<SupportsTransparency PixelType>
bool porytiles2::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 110 of file metatile.hpp.

◆ is_transparent() [2/2]

template<SupportsTransparency PixelType>
bool porytiles2::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 132 of file metatile.hpp.

◆ middle() [1/2]

template<SupportsTransparency PixelType>
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & porytiles2::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 236 of file metatile.hpp.

◆ middle() [2/2]

template<SupportsTransparency PixelType>
const PixelTile< PixelType > & porytiles2::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 220 of file metatile.hpp.

◆ operator==()

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

◆ set_bottom()

template<SupportsTransparency PixelType>
void porytiles2::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 203 of file metatile.hpp.

◆ set_middle()

template<SupportsTransparency PixelType>
void porytiles2::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 250 of file metatile.hpp.

◆ set_top()

template<SupportsTransparency PixelType>
void porytiles2::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 297 of file metatile.hpp.

◆ top() [1/2]

template<SupportsTransparency PixelType>
const std::array< PixelTile< PixelType >, metatile::tiles_per_metatile_layer > & porytiles2::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 283 of file metatile.hpp.

◆ top() [2/2]

template<SupportsTransparency PixelType>
const PixelTile< PixelType > & porytiles2::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 267 of file metatile.hpp.


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