35#ifndef TCOD_CONSOLE_H_
36#define TCOD_CONSOLE_H_
67 TCOD_BKGND_COLOR_DODGE,
68 TCOD_BKGND_COLOR_BURN,
92 TCODLIB_BEGIN_IGNORE_DEPRECATIONS
96 [[deprecated]]
bool operator!=(
const TCOD_ConsoleTile& rhs)
const noexcept {
return !(*
this == rhs); }
97 TCODLIB_END_IGNORE_DEPRECATIONS
128 TCODLIB_BEGIN_IGNORE_DEPRECATIONS
136 [[nodiscard]] [[deprecated]]
auto begin()
const noexcept ->
const TCOD_ConsoleTile* {
return tiles; }
150 [[deprecated]]
void clear(
const TCOD_ConsoleTile& tile = {0x20, {255, 255, 255, 255}, {0, 0, 0, 255}})
noexcept {
151 for (
auto& it : *
this) it = tile;
156 [[nodiscard]] [[deprecated]]
auto operator[](
const std::array<int, 2>& xy)
noexcept ->
TCOD_ConsoleTile& {
157 return tiles[get_index(xy)];
162 [[nodiscard]] [[deprecated]]
auto operator[](
const std::array<int, 2>& xy)
const noexcept ->
const TCOD_ConsoleTile& {
163 return tiles[get_index(xy)];
170 [[nodiscard]] [[deprecated]]
auto at(
const std::array<int, 2>& xy) ->
TCOD_ConsoleTile& {
171 return tiles[bounds_check(xy)];
178 [[nodiscard]] [[deprecated]]
auto at(
const std::array<int, 2>& xy)
const ->
const TCOD_ConsoleTile& {
179 return tiles[bounds_check(xy)];
186 [[nodiscard]] [[deprecated]]
auto at(
int x,
int y) ->
TCOD_ConsoleTile& {
return at({x, y}); }
192 [[nodiscard]] [[deprecated]]
auto at(
int x,
int y)
const ->
const TCOD_ConsoleTile& {
return at({x, y}); }
198 [[nodiscard]] [[deprecated]]
int get_index(
const std::array<int, 2>& xy)
const noexcept {
return w * xy[1] + xy[0]; }
202 [[nodiscard]] [[deprecated]]
bool in_bounds(
const std::array<int, 2>& xy)
const noexcept {
203 return 0 <= xy[0] && xy[0] <
w && 0 <= xy[1] && xy[1] < h;
213 int bounds_check(
const std::array<int, 2>& xy)
const {
214 if (!in_bounds(xy)) {
215 throw std::out_of_range(
216 std::string(
"Out of bounds lookup {") + std::to_string(xy[0]) +
", " + std::to_string(xy[1]) +
217 "} on console of shape {" + std::to_string(
w) +
", " + std::to_string(h) +
"}.");
219 return get_index(xy);
221 TCODLIB_END_IGNORE_DEPRECATIONS
279TCOD_PUBLIC
void TCOD_console_set_key_color(
TCOD_Console* con, TCOD_color_t col);
311 float foreground_alpha,
312 float background_alpha);
313TCOD_PUBLIC
void TCOD_console_blit_key_color(
322 float foreground_alpha,
323 float background_alpha,
335TCOD_DEPRECATED(
"Console defaults have been deprecated.")
336TCOD_PUBLIC
void TCOD_console_set_default_background(
TCOD_Console* con, TCOD_color_t col);
337TCOD_DEPRECATED(
"Console defaults have been deprecated.")
338TCOD_PUBLIC
void TCOD_console_set_default_foreground(
TCOD_Console* con, TCOD_color_t col);
352TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
363TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
373TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
384TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
396TCOD_DEPRECATED(
"Replace with TCOD_console_put_rgb.")
404TCOD_DEPRECATED(
"Console defaults have been deprecated.")
409TCOD_DEPRECATED(
"Console defaults have been deprecated.")
417TCOD_DEPRECATED(
"Console defaults have been deprecated.")
422TCOD_DEPRECATED(
"Console defaults have been deprecated.")
424TCOD_DEPRECATED(
"Console defaults have been deprecated.")
425TCOD_PUBLIC TCOD_NODISCARD TCOD_color_t TCOD_console_get_default_background(
TCOD_Console* con);
426TCOD_DEPRECATED(
"Console defaults have been deprecated.")
427TCOD_PUBLIC TCOD_NODISCARD TCOD_color_t TCOD_console_get_default_foreground(
TCOD_Console* con);
455void 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:92
A libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console.h:125
void(* on_delete)(struct TCOD_Console *self)
Internal use.
Definition console.h:256
TCOD_bkgnd_flag_t bkgnd_flag
Default background operator for print & print_rect functions.
Definition console.h:230
TCOD_color_t key_color
The current key color for this console.
Definition console.h:238
TCOD_color_t fore
Foreground (text) and background colors.
Definition console.h:234
int elements
The total length of the tiles array.
Definition console.h:246
int w
Console width and height in tiles.
Definition console.h:226
bool has_key_color
True if a key color is being used.
Definition console.h:236
TCOD_ConsoleTile * tiles
A contiguous array of console tiles.
Definition console.h:228
TCOD_alignment_t alignment
Default alignment for print & print_rect functions.
Definition console.h:232
void * userdata
A userdata attribute which can be repurposed.
Definition console.h:254
The raw data for a single TCOD_Console tile.
Definition console.h:89
TCOD_ColorRGBA fg
The tile glyph color, rendered on top of the background.
Definition console.h:107
int ch
The Unicode codepoint for this tile.
Definition console.h:103
TCOD_ColorRGBA bg
The tile background color, rendered behind the glyph.
Definition console.h:111