palette: add necessary predicates #230

pull/287/head
nick black 5 years ago committed by Nick Black
parent 0e70304596
commit 209d4f41f4

@ -932,12 +932,18 @@ channel_set_alpha(unsigned* channel, int alpha){
return 0;
}
// Is this channel using the "default color" rather than its RGB?
// Is this channel using the "default color" rather than RGB/palette-indexed?
static inline bool
channel_default_p(unsigned channel){
return !(channel & CELL_BGDEFAULT_MASK);
}
// Is this channel using palette-indexed color rather than RGB?
static inline bool
channel_palindex_p(unsigned channel){
return !channel_default_p(channel) && (channel & CELL_BG_PALETTE);
}
// Mark the channel as using its default color, which also marks it opaque.
static inline unsigned
channel_set_default(unsigned* channel){
@ -1096,6 +1102,12 @@ channels_fg_default_p(uint64_t channels){
return channel_default_p(channels_fchannel(channels));
}
// Is the foreground using indexed palette color?
static inline bool
channels_fg_palindex_p(uint64_t channels){
return channel_palindex_p(channels_fchannel(channels));
}
// Is the background using the "default background color"? The "default
// background color" must generally be used to take advantage of
// terminal-effected transparency.
@ -1104,6 +1116,12 @@ channels_bg_default_p(uint64_t channels){
return channel_default_p(channels_bchannel(channels));
}
// Is the background using indexed palette color?
static inline bool
channels_bg_palindex_p(uint64_t channels){
return channel_palindex_p(channels_bchannel(channels));
}
// Mark the foreground channel as using its default color.
static inline uint64_t
channels_set_fg_default(uint64_t* channels){
@ -1301,6 +1319,11 @@ cell_fg_default_p(const cell* cl){
return channels_fg_default_p(cl->channels);
}
static inline bool
cell_fg_palindex_p(const cell* cl){
return channels_fg_palindex_p(cl->channels);
}
// Is the background using the "default background color"? The "default
// background color" must generally be used to take advantage of
// terminal-effected transparency.
@ -1309,6 +1332,11 @@ cell_bg_default_p(const cell* cl){
return channels_bg_default_p(cl->channels);
}
static inline bool
cell_bg_palindex_p(const cell* cl){
return channels_bg_palindex_p(cl->channels);
}
// Get the current channels or attribute word for ncplane 'n'.
API uint64_t ncplane_channels(const struct ncplane* n);
API uint32_t ncplane_attr(const struct ncplane* n);

@ -271,6 +271,7 @@ paint(notcurses* nc, ncplane* p, struct crender* rvec, cell* fb){
cell_set_wide(targc);
}
}
// FIXME blend in palette-indexed colors?
if(cell_fg_alpha(targc) > CELL_ALPHA_OPAQUE && cell_fg_alpha(vis) < CELL_ALPHA_TRANSPARENT){
cell_blend_fchannel(targc, cell_fchannel(vis), crender->fgblends);
++crender->fgblends;

Loading…
Cancel
Save