Porytiles
Loading...
Searching...
No Matches
porytiles2::tile Namespace Reference

Functions

constexpr std::pair< std::size_t, std::size_t > index_to_row_col (std::size_t index)
 Converts a linear index to row and column coordinates.
 
constexpr std::size_t row_col_to_index (std::size_t row, std::size_t col)
 Converts row and column coordinates to a linear index.
 

Variables

constexpr std::size_t side_length_pix = 8
 
constexpr std::size_t size_pix = side_length_pix * side_length_pix
 

Function Documentation

◆ index_to_row_col()

constexpr std::pair< std::size_t, std::size_t > porytiles2::tile::index_to_row_col ( std::size_t  index)
constexpr

Converts a linear index to row and column coordinates.

Takes a linear index in the range [0, size_pix) and returns the corresponding row and column coordinates in an 8x8 tile grid. The row is the first element of the returned pair, and the column is the second element.

Parameters
indexThe linear index to convert
Returns
A pair containing (row, col) coordinates

Definition at line 27 of file pixel_tile.hpp.

◆ row_col_to_index()

constexpr std::size_t porytiles2::tile::row_col_to_index ( std::size_t  row,
std::size_t  col 
)
constexpr

Converts row and column coordinates to a linear index.

Takes row and column coordinates in an 8x8 tile grid and returns the corresponding linear index in the range [0, size_pix).

Parameters
rowThe row coordinate
colThe column coordinate
Returns
The linear index

Definition at line 43 of file pixel_tile.hpp.

Variable Documentation

◆ side_length_pix

constexpr std::size_t porytiles2::tile::side_length_pix = 8
inlineconstexpr

Definition at line 14 of file pixel_tile.hpp.

◆ size_pix

constexpr std::size_t porytiles2::tile::size_pix = side_length_pix * side_length_pix
inlineconstexpr

Definition at line 15 of file pixel_tile.hpp.