< index < 2. Console emulator < 2.2 Drawing on the root console |
===================================== |
TCOD_COLCTRL_1 TCOD_COLCTRL_2 TCOD_COLCTRL_3 TCOD_COLCTRL_4 TCOD_COLCTRL_5To associate a color with a code, use setColorControl.
TCOD_COLCTRL_STOPExample :
C++ : TCODConsole::setColorControl(TCOD_COLCTRL_1,TCODColor::red,TCODColor::black); TCODConsole::root->printLeft(1,1,TCOD_BKGND_SET, "String with a %cred%c word.",TCOD_COLCTRL_1,TCOD_COLCTRL_STOP); C : TCOD_console_set_color_control(TCOD_COLCTRL_1,red,black); TCOD_console_print_left(NULL,1,1,TCOD_BKGND_SET, "String with a %cred%c word.",TCOD_COLCTRL_1,TCOD_COLCTRL_STOP); Py : libtcod.console_set_color_control(libtcod.COLCTRL_1,litbcod.red,litbcod.black) libtcod.console_print_left(0,1,1,libtcod.BKGND_SET, "String with a %cred%c word."%(libtcod.COLCTRL_1,libtcod.COLCTRL_STOP))You can also use any color without assigning it to a control code, using the generic control codes :
TCOD_COLCTRL_FORE_RGB TCOD_COLCTRL_BACK_RGBThose controls respectively change the foreground and background color used to print the string characters. In the string, you must insert the r,g,b components of the color (between 1 and 255. The value 0 is forbidden because it represents the end of the string in C/C++) immediately after this code.
C++ : TCODConsole::root->printLeft(1,1,TCOD_BKGND_SET, "String with a %c%c%c%cred%c word.",TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_STOP); C : TCOD_console_print_left(NULL,1,1,TCOD_BKGND_SET, "String with a %c%c%c%cred%c word.",TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_STOP); Py : litbcod.console_print_left(0,1,1,libtcod.BKGND_SET, "String with a %c%c%c%cred%c word."%(libtcod.COLCTRL_FORE_RGB,255,1,1,libtcod.COLCTRL_STOP))A string with a red over black word, using generic color control codes :
C++ : TCODConsole::root->printLeft(1,1,TCOD_BKGND_SET, "String with a %c%c%c%c%c%c%c%cred%c word.", TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_BACK_RGB,1,1,1,TCOD_COLCTRL_STOP); C : TCOD_console_print_left(NULL,1,1,TCOD_BKGND_SET, "String with a %c%c%c%c%c%c%c%cred%c word.", TCOD_COLCTRL_FORE_RGB,255,1,1,TCOD_COLCTRL_BACK_RGB,1,1,1,TCOD_COLCTRL_STOP); Py : libtcod.console_print_left(0,1,1,libtcod.BKGND_SET, "String with a %c%c%c%c%c%c%c%cred%c word."% (libtcod.COLCTRL_FORE_RGB,255,1,1,libtcod.COLCTRL_BACK_RGB,1,1,1,libtcod.COLCTRL_STOP))