Logo Search packages:      
Sourcecode: libcaca version File versions  Download package

void caca_set_color ( enum caca_color  fgcolor,
enum caca_color  bgcolor 
)

Set the default colour pair.

This function sets the default colour pair. String functions such as caca_printf() and graphical primitive functions such as caca_draw_line() will use these colour pairs.

Parameters:
fgcolor The requested foreground colour.
bgcolor The requested background colour.

Definition at line 272 of file graphics.c.

References CACA_COLOR_BLACK, CACA_COLOR_LIGHTGRAY, and CACA_COLOR_WHITE.

Referenced by caca_clear(), caca_draw_bitmap(), and caca_draw_sprite().

{
    if(fgcolor < 0 || fgcolor > 15 || bgcolor < 0 || bgcolor > 15)
        return;

    _caca_fgcolor = fgcolor;
    _caca_bgcolor = bgcolor;

    switch(_caca_driver)
    {
#if defined(USE_SLANG)
    case CACA_DRIVER_SLANG:

#if defined(OPTIMISE_SLANG_PALETTE)
        /* If foreground == background, discard this colour pair. Functions
         * such as caca_putchar will print spaces instead of characters */
        if(fgcolor != bgcolor)
            _caca_fgisbg = 0;
        else
        {
            _caca_fgisbg = 1;
            if(fgcolor == CACA_COLOR_BLACK)
                fgcolor = CACA_COLOR_WHITE;
            else if(fgcolor == CACA_COLOR_WHITE
                     || fgcolor <= CACA_COLOR_LIGHTGRAY)
                fgcolor = CACA_COLOR_BLACK;
            else
                fgcolor = CACA_COLOR_WHITE;
        }
#endif

#if defined(OPTIMISE_SLANG_PALETTE)
        SLsmg_set_color(slang_assoc[fgcolor + 16 * bgcolor]);
#else
        SLsmg_set_color(fgcolor + 16 * bgcolor);
#endif
        break;
#endif
#if defined(USE_NCURSES)
    case CACA_DRIVER_NCURSES:
        attrset(ncurses_attr[fgcolor + 16 * bgcolor]);
        break;
#endif
#if defined(USE_CONIO)
    case CACA_DRIVER_CONIO:
        textbackground(bgcolor);
        textcolor(fgcolor);
        break;
#endif
#if defined(USE_X11)
    case CACA_DRIVER_X11:
        /* Nothing to do */
        break;
#endif
#if defined(USE_WIN32)
    case CACA_DRIVER_WIN32:
        /* Nothing to do */
        break;
#endif
    default:
        break;
    }
}


Generated by  Doxygen 1.6.0   Back to index