libtcoddocumentation

2.2.1. Basic printing functions

Setting the default background color

This function changes the default background color for a console. The default background color is used by several drawing functions like clear, putChar, ...

void TCODConsole::setDefaultBackground(TCODColor back)

void TCOD_console_set_default_background(TCOD_console_t con,TCOD_color_t back)

console_set_default_background(con,back)

void TCODConsole::setBackgroundColor(TCODColor back)

libtcod.TCODConsole_root:setBackgroundColor( myColor )

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
backthe new default background color for this console
Example:

TCODConsole::root->setDefaultBackground(myColor)

TCOD_console_set_default_background(NULL, my_color)

litbcod.console_set_default_background(0, my_color)


Setting the default foreground color

This function changes the default foreground color for a console. The default foreground color is used by several drawing functions like clear, putChar, ...

void TCODConsole::setDefaultForeground(TCODColor fore)

void TCOD_console_set_default_foreground(TCOD_console_t con,TCOD_color_t fore)

console_set_default_foreground(con, fore)

void TCODConsole::setForegroundColor(TCODColor fore)

Console:setForegroundColor(fore)

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
forethe new default foreground color for this console
Example:

TCODConsole::root->setDefaultForeground(myColor)

TCOD_console_set_default_foreground(NULL, my_color)

litbcod.console_set_default_foreground(0, my_color)

libtcod.TCODConsole_root:setForegroundColor( myColor )


Clearing a console

This function modifies all cells of a console :
* set the cell's background color to the console default background color
* set the cell's foreground color to the console default foreground color
* set the cell's ASCII code to 32 (space)

void TCODConsole::clear()

void TCOD_console_clear(TCOD_console_t con)

console_clear(con)

void TCODConsole::clear()

Console:clear()

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console

Setting the background color of a cell

This function modifies the background color of a cell, leaving other properties (foreground color and ASCII code) unchanged.

void TCODConsole::setCharBackground(int x, int y, const TCODColor &col, TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET)

void TCOD_console_set_char_background(TCOD_console_t con,int x, int y, TCOD_color_t col, TCOD_bkgnd_flag_t flag)

console_set_char_background(con, x, y, col, flag=BKGND_SET)

void TCODConsole::setCharBackground(int x, int y, TCODColor col)
void
TCODConsole::setCharBackground(int x, int y, TCODColor col, TCODBackgroundFlag flag)

Console:setCharBackground(x, y, col)
Console:setCharBackground(x, y, col, flag)

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
x,ycoordinates of the cell in the console.
0 <= x < console width
0 <= y < console height
colthe background color to use. You can use color constants
flagthis flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t

Setting the foreground color of a cell

This function modifies the foreground color of a cell, leaving other properties (background color and ASCII code) unchanged.

void TCODConsole::setCharForeground(int x, int y, const TCODColor &col)

void TCOD_console_set_char_foreground(TCOD_console_t con,int x, int y, TCOD_color_t col)

console_set_char_foreground(con, x, y, col)

void TCODConsole::setCharForeground(int x, int y, TCODColor col)

Console:setCharForeground(x, y, col)

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
x,ycoordinates of the cell in the console.
0 <= x < console width
0 <= y < console height
colthe foreground color to use. You can use color constants

Setting the ASCII code of a cell

This function modifies the ASCII code of a cell, leaving other properties (background and foreground colors) unchanged.
Note that since a clear console has both background and foreground colors set to black for every cell, using setchar will produce black characters on black background. Use putchar instead.

void TCODConsole::setChar(int x, int y, int c)

void TCOD_console_set_char(TCOD_console_t con,int x, int y, int c)

console_set_char(con, x, y, c)

void TCODConsole::setChar(int x, int y, int c)

Console:setChar(x, y, c)

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
x,ycoordinates of the cell in the console.
0 <= x < console width
0 <= y < console height
cthe new ASCII code for the cell. You can use ASCII constants

Setting every property of a cell using default colors

This function modifies every property of a cell :
* update the cell's background color according to the console default background color (see TCOD_bkgnd_flag_t).
* set the cell's foreground color to the console default foreground color
* set the cell's ASCII code to c

void TCODConsole::putChar(int x, int y, int c, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT)

void TCOD_console_put_char(TCOD_console_t con,int x, int y, int c, TCOD_bkgnd_flag_t flag)

console_put_char( con, x, y, c, flag=BKGND_DEFAULT)

void TCODConsole::putChar(int x, int y, int c)
void
TCODConsole::putChar(int x, int y, int c, TCODBackgroundFlag flag)

Console:putChar(x, y, c)
Console:putChar(x, y, c, flag)

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
x,ycoordinates of the cell in the console.
0 <= x < console width
0 <= y < console height
cthe new ASCII code for the cell. You can use ASCII constants
flagthis flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t

Setting every property of a cell using specific colors

This function modifies every property of a cell :
* set the cell's background color to back.
* set the cell's foreground color to fore.
* set the cell's ASCII code to c.

void TCODConsole::putCharEx(int x, int y, int c, const TCODColor & fore, const TCODColor & back)

void TCOD_console_put_char_ex(TCOD_console_t con,int x, int y, int c, TCOD_color_t fore, TCOD_color_t back)

console_put_char_ex( con, x, y, c, fore, back)

void TCODConsole::putCharEx(int x, int y, int c, TCODColor fore, TCODColor back)

Console:putCharEx(x, y, c, fore, back)

ParameterDescription
conin the C and Python versions, the offscreen console handler or NULL for the root console
x,ycoordinates of the cell in the console.
0 <= x < console width
0 <= y < console height
cthe new ASCII code for the cell. You can use ASCII constants
fore,backnew foreground and background colors for this cell