< index < 2. Console < 2.4 Using off-screen consoles | ===================================== 2.4.2 Blitting a console on another one ===================================== |

    C++ : static void blit(const TCODConsole *src,int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole *dst, int xDst, int yDst, float foregroundAlpha=1.0f, float backgroundAlpha=1.0f)
    C   : void TCOD_console_blit(TCOD_console_t src,int xSrc, int ySrc, int wSrc, int hSrc, TCOD_console_t dst, int xDst, int yDst, float foreground_alpha, float background_alpha)
    Py  : console_blit(src,xSrc,ySrc,xSrc,hSrc,dst,xDst,yDst,foregroundAlpha=1.0,backgroundAlpha=1.0)

This function allows you to blit a rectangular area of the source console at a specific position on a destination console. It can also simulate alpha transparency with the fade parameter.

Parameter | Description
--- | ---
src | The source console that must be blitted on another one.
xSrc, ySrc, wSrc, hSrc | The rectangular area of the source console that will be blitted.
dst | The destination console.
xDst, yDst | Where to blit the upper-left corner of the source area in the destination console.
foregroundAlpha,backgroundAlpha | Alpha transparency of the blitted console. 0.0 => The source console is completely transparent. This function does nothing. 1.0 => The source console is opaque. Its cells replace the destination cells. 0 < fade < 1.0 => The source console is partially blitted, simulating real transparency.

Example :
Cross-fading between two offscreen consoles. We use two offscreen consoles with the same size as the root console. We render a different screen on each offscreen console. When the user hits a key, we do a cross-fading from the first screen to the second screen.

    C++ : TCODConsole *off1 = new TCODConsole(80,50);
          TCODConsole *off2 = new TCODConsole(80,50);
          ... print screen1 on off1
          ... print screen2 of off2
          // render screen1 in the game window
          TCODConsole::blit(off1,0,0,80,50,TCODConsole::root,0,0);
          TCODConsole::flush();
          // wait or a keypress
          TCODConsole::waitForKeypress(true);
          // do a cross-fading from off1 to off2
          for (int i=1; i <= 255; i++) {
              TCODConsole::blit(off1,0,0,80,50,TCODConsole::root,0,0); // renders the first screen (opaque)
              TCODConsole::blit(off2,0,0,80,50,TCODConsole::root,0,0,i/255.0,i/255.0); // renders the second screen (transparent)
              TCODConsole::flush();
    	  }
    C   : TCOD_console_t off1 = TCOD_console_new(80,50);
          TCOD_console_t off2 = TCOD_console_new(80,50);
          int i;
          ... print screen1 on off1
          ... print screen2 of off2
          /* render screen1 in the game window */
          TCOD_console_blit(off1,0,0,80,50,NULL,0,0,1.0,1.0);
          TCOD_console_flush();
          /* wait or a keypress */
          TCOD_console_wait_for_keypress(true);
          /* do a cross-fading from off1 to off2 */
          for (i=1; i <= 255; i++) {
              TCOD_console_blit(off1,0,0,80,50,NULL,0,0,1.0,1.0); /* renders the first screen (opaque) */
              TCOD_console_blit(off2,0,0,80,50,NULL,0,0,i/255.0,i/255.0); /* renders the second screen (transparent) */
              TCOD_console_flush();
    	  }
    Py  : off1 = libtcod.console_new(80,50)
          off2 = libtcod.console_new(80,50)
          ... print screen1 on off1
          ... print screen2 of off2
          # render screen1 in the game window
          libtcod.console_blit(off1,0,0,80,50,0,0,0)
          libtcod.console_flush()
          # wait or a keypress
          libtcod.console_wait_for_keypress(True)
          # do a cross-fading from off1 to off2
          for i in range(1,256) :
              litbcod.console_blit(off1,0,0,80,50,0,0,0) # renders the first screen (opaque)
              litbcod.console_blit(off2,0,0,80,50,0,0,0,i/255.0,i/255.0) # renders the second screen (transparent)
              litbcod.console_flush()

    C++ : void TCODConsole::setKeyColor(const TCODColor &col)
    C   : void TCOD_console_set_key_color(TCOD_console_t con,TCOD_color_t col)
    Py  : console_set_key_color(con,col)

This function defines a transparent background color for an offscreen console. All cells with this background color are ignored by the blit operation. You can use it to blit only some parts of the console.

Parameter | Description
--- | ---
con | In the C version, the offscreen console handler or NULL for the root console.
col | The transparent background color.