35#ifndef TCOD_CONSOLE_H_
36#define TCOD_CONSOLE_H_
67 TCOD_BKGND_COLOR_DODGE,
68 TCOD_BKGND_COLOR_BURN,
90 TCODLIB_BEGIN_IGNORE_DEPRECATIONS
94 [[deprecated]]
bool operator!=(
const TCOD_ConsoleTile& rhs)
const noexcept {
return !(*
this == rhs); }
95 TCODLIB_END_IGNORE_DEPRECATIONS
124 TCODLIB_BEGIN_IGNORE_DEPRECATIONS
132 [[nodiscard]] [[deprecated]]
auto begin()
const noexcept ->
const TCOD_ConsoleTile* {
return tiles; }
146 [[deprecated]]
void clear(
const TCOD_ConsoleTile& tile = {0x20, {255, 255, 255, 255}, {0, 0, 0, 255}})
noexcept {
147 for (
auto& it : *
this) it = tile;
152 [[nodiscard]] [[deprecated]]
auto operator[](
const std::array<int, 2>& xy)
noexcept ->
TCOD_ConsoleTile& {
153 return tiles[get_index(xy)];
158 [[nodiscard]] [[deprecated]]
auto operator[](
const std::array<int, 2>& xy)
const noexcept ->
const TCOD_ConsoleTile& {
159 return tiles[get_index(xy)];
166 [[nodiscard]] [[deprecated]]
auto at(
const std::array<int, 2>& xy) ->
TCOD_ConsoleTile& {
167 return tiles[bounds_check(xy)];
174 [[nodiscard]] [[deprecated]]
auto at(
const std::array<int, 2>& xy)
const ->
const TCOD_ConsoleTile& {
175 return tiles[bounds_check(xy)];
182 [[nodiscard]] [[deprecated]]
auto at(
int x,
int y) ->
TCOD_ConsoleTile& {
return at({x, y}); }
188 [[nodiscard]] [[deprecated]]
auto at(
int x,
int y)
const ->
const TCOD_ConsoleTile& {
return at({x, y}); }
194 [[nodiscard]] [[deprecated]]
int get_index(
const std::array<int, 2>& xy)
const noexcept {
return w * xy[1] + xy[0]; }
198 [[nodiscard]] [[deprecated]]
bool in_bounds(
const std::array<int, 2>& xy)
const noexcept {
199 return 0 <= xy[0] && xy[0] <
w && 0 <= xy[1] && xy[1] < h;
209 int bounds_check(
const std::array<int, 2>& xy)
const {
210 if (!in_bounds(xy)) {
211 throw std::out_of_range(
212 std::string(
"Out of bounds lookup {") + std::to_string(xy[0]) +
", " + std::to_string(xy[1]) +
213 "} on console of shape {" + std::to_string(
w) +
", " + std::to_string(h) +
"}.");
215 return get_index(xy);
217 TCODLIB_END_IGNORE_DEPRECATIONS
275TCOD_PUBLIC
void TCOD_console_set_key_color(
TCOD_Console* con, TCOD_color_t col);
307 float foreground_alpha,
308 float background_alpha);
309TCOD_PUBLIC
void TCOD_console_blit_key_color(
318 float foreground_alpha,
319 float background_alpha,
331TCOD_DEPRECATED(
"Console defaults have been deprecated.")
332TCOD_PUBLIC
void TCOD_console_set_default_background(
TCOD_Console* con, TCOD_color_t col);
333TCOD_DEPRECATED(
"Console defaults have been deprecated.")
334TCOD_PUBLIC
void TCOD_console_set_default_foreground(
TCOD_Console* con, TCOD_color_t col);
348TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
359TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
369TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
380TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
392TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
400TCOD_DEPRECATED(
"Console defaults have been deprecated.")
405TCOD_DEPRECATED(
"Console defaults have been deprecated.")
413TCOD_DEPRECATED(
"Console defaults have been deprecated.")
418TCOD_DEPRECATED(
"Console defaults have been deprecated.")
420TCOD_DEPRECATED(
"Console defaults have been deprecated.")
421TCOD_PUBLIC TCOD_NODISCARD TCOD_color_t TCOD_console_get_default_background(
TCOD_Console* con);
422TCOD_DEPRECATED(
"Console defaults have been deprecated.")
423TCOD_PUBLIC TCOD_NODISCARD TCOD_color_t TCOD_console_get_default_foreground(
TCOD_Console* con);
451void TCOD_console_resize_(
TCOD_Console* console,
int width,
int height);
int TCOD_console_get_width(const TCOD_Console *con)
Return the width of a console.
TCOD_color_t TCOD_console_get_char_background(const TCOD_Console *con, int x, int y)
Return the background color of a console at x,y.
TCOD_color_t TCOD_console_get_char_foreground(const TCOD_Console *con, int x, int y)
Return the foreground color of a console at x,y.
void TCOD_console_put_char_ex(TCOD_Console *con, int x, int y, int c, TCOD_color_t fore, TCOD_color_t back)
Draw a character on the console with the given colors.
void TCOD_console_set_background_flag(TCOD_Console *con, TCOD_bkgnd_flag_t flag)
Set a consoles default background flag.
void TCOD_console_blit(const TCOD_Console *src, int xSrc, int ySrc, int wSrc, int hSrc, TCOD_Console *dst, int xDst, int yDst, float foreground_alpha, float background_alpha)
Blit from one console to another.
TCOD_alignment_t
Print justification options.
Definition console.h:81
int TCOD_console_get_char(const TCOD_Console *con, int x, int y)
Return a character code of a console at x,y.
TCOD_bkgnd_flag_t
Background color blend modes.
Definition console.h:60
void TCOD_console_delete(TCOD_Console *console)
Delete a console.
void TCOD_console_set_char_background(TCOD_Console *con, int x, int y, TCOD_color_t col, TCOD_bkgnd_flag_t flag)
Blend a background color onto a console tile.
void TCOD_console_put_char(TCOD_Console *con, int x, int y, int c, TCOD_bkgnd_flag_t flag)
Draw a character on a console using the default colors.
int TCOD_console_get_height(const TCOD_Console *con)
Return the height of a console.
void TCOD_console_set_alignment(TCOD_Console *con, TCOD_alignment_t alignment)
Set a consoles default alignment.
TCOD_alignment_t TCOD_console_get_alignment(TCOD_Console *con)
Return a consoles default alignment.
TCOD_Console * TCOD_console_new(int w, int h)
Return a new console with a specific number of columns and rows.
void TCOD_console_set_char(TCOD_Console *con, int x, int y, int c)
Change a character on a console tile, without changing its colors.
TCOD_bkgnd_flag_t TCOD_console_get_background_flag(TCOD_Console *con)
Return a consoles default background flag.
void TCOD_console_clear(TCOD_Console *con)
Clear a console to its default colors and the space character code.
void TCOD_console_set_char_foreground(TCOD_Console *con, int x, int y, TCOD_color_t col)
Change the foreground color of a console tile.
A 4-channel RGBA color struct.
Definition color.h:89
A libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console.h:121
void(* on_delete)(struct TCOD_Console *self)
Internal use.
Definition console.h:252
TCOD_bkgnd_flag_t bkgnd_flag
Default background operator for print & print_rect functions.
Definition console.h:226
TCOD_color_t key_color
The current key color for this console.
Definition console.h:234
TCOD_color_t fore
Foreground (text) and background colors.
Definition console.h:230
int elements
The total length of the tiles array.
Definition console.h:242
int w
Console width and height in tiles.
Definition console.h:222
bool has_key_color
True if a key color is being used.
Definition console.h:232
TCOD_ConsoleTile * tiles
A contiguous array of console tiles.
Definition console.h:224
TCOD_alignment_t alignment
Default alignment for print & print_rect functions.
Definition console.h:228
void * userdata
A userdata attribute which can be repurposed.
Definition console.h:250
The raw data for a single TCOD_Console tile.
Definition console.h:87
TCOD_ColorRGBA fg
The tile glyph color, rendered on top of the background.
Definition console.h:105
int ch
The Unicode codepoint for this tile.
Definition console.h:101
TCOD_ColorRGBA bg
The tile background color, rendered behind the glyph.
Definition console.h:109