Struct TCOD_Console¶
Defined in File console.h
Struct Documentation¶
-
struct TCOD_Console
A libtcod console containing a grid of tiles with
{ch, fg, bg}
information.In C++ this struct has several convience methods to make working with consoles easier. Note that all tile references are to TCOD_ConsoleTile structs and will include an alpha channel.
For C++ code examples see
tcod::Console
.New in version 1.19.
Public Functions
-
inline auto begin() noexcept -> TCOD_ConsoleTile*
Return a pointer to the beginning of this consoles tile data.
-
inline auto begin() const noexcept -> const TCOD_ConsoleTile*
Return a const pointer to the beginning of this consoles tile data.
-
inline auto end() noexcept -> TCOD_ConsoleTile*
Return a pointer to the end of this consoles tile data.
-
inline auto end() const noexcept -> const TCOD_ConsoleTile*
Return a const pointer to the end of this consoles tile data.
-
inline void clear(const TCOD_ConsoleTile &tile = {0x20, {255, 255, 255, 255}, {0, 0, 0, 255}}) noexcept
Clear a console by setting all tiles to the provided TCOD_ConsoleTile object.
- Parameters
tile – A TCOD_ConsoleTile reference which will be used to clear the console.
-
inline auto operator[](const std::array<int, 2> &xy) noexcept -> TCOD_ConsoleTile&
Return a reference to the tile at
xy
.
-
inline auto operator[](const std::array<int, 2> &xy) const noexcept -> const TCOD_ConsoleTile&
Return a constant reference to the tile at
xy
.
-
inline auto at(const std::array<int, 2> &xy) -> TCOD_ConsoleTile&
Return a reference to the tile at
xy
.- Throws
std::out_of_range – if the index is out-of-bounds
-
inline auto at(const std::array<int, 2> &xy) const -> const TCOD_ConsoleTile&
Return a constant reference to the tile at
xy
.- Throws
std::out_of_range – if the index is out-of-bounds
-
inline auto at(int x, int y) -> TCOD_ConsoleTile&
Return a reference to the tile at
x
,y
.- Throws
std::out_of_range – if the index is out-of-bounds
-
inline auto at(int x, int y) const -> const TCOD_ConsoleTile&
Return a constant reference to the tile at
x
,y
.- Throws
std::out_of_range – if the index is out-of-bounds
-
inline int get_index(const std::array<int, 2> &xy) const noexcept
Convert
xy
into a 1-dimensional index.Out-of-bounds indexes are undefined.
This index is normally used to index the tiles attribute.
-
inline bool in_bounds(const std::array<int, 2> &xy) const noexcept
Return true if
xy
are within the bounds of this console.
Public Members
-
int w
Console width and height in tiles.
-
int h
-
TCOD_ConsoleTile *tiles
A contiguous array of console tiles.
-
TCOD_bkgnd_flag_t bkgnd_flag
Default background operator for print & print_rect functions.
-
TCOD_alignment_t alignment
Default alignment for print & print_rect functions.
-
TCOD_color_t fore
Foreground (text) and background colors.
-
TCOD_color_t back
-
bool has_key_color
True if a key color is being used.
-
TCOD_color_t key_color
The current key color for this console.
-
int elements
The total length of the tiles array.
Same as
w * h
.New in version 1.16.
-
void *userdata
A userdata attribute which can be repurposed.
New in version 1.16.
-
void (*on_delete)(struct TCOD_Console *self)
Internal use.
-
inline auto begin() noexcept -> TCOD_ConsoleTile*