Function tcod::draw_rect

Function Documentation

inline void tcod::draw_rect(TCOD_Console &console, const std::array<int, 4> &rect, int ch, std::optional<TCOD_ColorRGB> fg, std::optional<TCOD_ColorRGB> bg, TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET)

Fill a region with the given graphic.

auto console = tcod::Console{80, 50};
// Draw a red background without replacing any foreground glyphs/colors.
tcod::draw_rect(console, {2, 2, 24, 24}, 0, std::nullopt, tcod::ColorRGB{255, 0, 0});
// Draw a horizontal bar.
tcod::draw_rect(console, {8, 8, 16, 1}, '-', {{255, 255, 255}}, std::nullopt);

New in version 1.19.

Parameters
  • console – A reference to a TCOD_Console.

  • rect – An {x, y, width, height} rectangle, starting from the upper-left-most tile as zero.

  • ch – The character to draw. If zero then the characters in the drawing region will not be changed.

  • 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.

  • flag – The background blending flag.