Function tcod::print

Function Documentation

inline void tcod::print(TCOD_Console &console, const std::array<int, 2> &xy, std::string_view str, std::optional<TCOD_ColorRGB> fg, std::optional<TCOD_ColorRGB> bg, TCOD_alignment_t alignment = TCOD_LEFT, TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET)

Print a string to a console.

auto console = tcod::Console{80, 50};
tcod::print(console, {0, 0}, "Hello World", {{255, 255, 255}}, {{0, 0, 0}});

New in version 1.19.

Parameters
  • console – A reference to a TCOD_Console.

  • xy – The starting {x, y} position, starting from the upper-left-most tile as zero.

  • str – The text to print. This string can contain libtcod color codes.

  • fg – The foreground color. The printed text is set to this color. If std::nullopt then the foreground will be left unchanged, inheriting the previous value of the tile.

  • bg – The background color. The background tile under the printed text is set to this color. If std::nullopt then the background will be left unchanged.

  • alignment – The text justification.

  • flag – The background blending flag.