notcurses_palette - operations on notcurses palettes
Contents
Description
Some terminals only support 256 colors, but allow the full palette to be specified with arbitrary RGB
colors. In all cases, it's more performant to use indexed colors, since it's much less data to write to
the terminal. If you can limit yourself to 256 colors, that's probably for the best.
In addition, palette-based color allows for very fast color cycling effects, since a single command can
affect many cells on the screen.
Name
notcurses_palette - operations on notcurses palettes
Return Values
Functions returning int return -1 on failure, or 0 on success. Failure is always due to invalid inputs.
Functions returning bool are predicates, and return the requested value. Functions returning unsigned
forms return the input, modified as requested.
See Also
notcurses(3), notcurses_cell(3), notcurses_channels(3), notcurses_output(3), notcurses_plane(3)
Synopsis
#include<notcurses/notcurses.h>
typedef struct ncpalette {
// We store the RGB values as a regular ol' channel
uint32_t chans[NCPALETTESIZE];
} ncpalette;
boolnotcurses_cantruecolor(conststructnotcurses*nc);ncpalette*ncpalette_new(structnotcurses*nc);intncpalette_use(structnotcurses*nc,constncpalette*p);intncpalette_set_rgb8(ncpalette*p,intidx,intr,intg,intb);intncpalette_set(ncpalette*p,intidx,unsignedrgb);intncpalette_get(constncpalette*p,intidx,uint32_t*palent);intncpalette_get_rgb8(constncpalette*p,intidx,int*restrictr,int*restrictg,int*restrictb);voidncpalette_free(ncpalette*p);boolnotcurses_canchangecolors(conststructnotcurses*nc);