Type Definition libnotcurses_sys::NcChannels [−][src]
pub type NcChannels = u64;
Expand description
64 bits containing a foreground and background NcChannel
(alias of u64
).
At render time, both 24-bit NcRgb
values are quantized down to terminal
capabilities, if necessary. There’s a clear path to 10-bit support should
we one day need it.
Default Color
The “default color” is best explained by color(3NCURSES) and default_colors(3NCURSES). Ours is the same concept.
Until the “not default color” bit is set, any color you load will be ignored.
Diagram
~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB║~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB
↑↑↑↑↑↑↑↑↑↑↑↑ foreground ↑↑↑↑↑↑↑↑↑↑↑║↑↑↑↑↑↑↑↑↑↑↑↑ background ↑↑↑↑↑↑↑↑↑↑↑
Detailed info (specially on the context-dependent bits on each
NcChannel
’s 4th byte):
~foreground channel~
reserved, must be 0 ↓bits view↓ ↓hex mask↓
0·······|········|········|········║········|········|········|········ = 8·······|········
NcChannels::FG_DEFAULT_MASK: foreground is NOT "default color"
·1······|········|········|········║········|········|········|········ = 4·······|········
NcChannels::FG_ALPHA_MASK: foreground alpha (2bits)
··11····|········|········|········║········|········|········|········ = 3·······|········
NcChannels::FG_PALETTE: foreground uses palette index
····1···|········|········|········║········|········|········|········ = ·8······|········
NcChannels::NOBACKGROUND_MASK: glyph is entirely foreground
·····1··|········|········|········║········|········|········|········ = ·4······|········
reserved, must be 0
······00|········|········|········║········|········|········|········ = ·3······|········
NcChannels::FG_RGB_MASK: foreground in 3x8 RGB (rrggbb)
········|11111111|11111111|11111111║········|········|········|········ = ··FFFFFF|········
~background channel~
reserved, must be 0 ↓bits view↓ ↓hex mask↓
········|········|········|········║0·······|········|········|········ = ········|8·······
NcChannels::BGDEFAULT_MASK: background is NOT "default color"
········|········|········|········║·1······|········|········|········ = ········|4·······
NcChannels::BG_ALPHA_MASK: background alpha (2 bits)
········|········|········|········║··11····|········|········|········ = ········|3·······
NcChannels::BG_PALETTE: background uses palette index
········|········|········|········║····1···|········|········|········ = ········|·8······
reserved, must be 0
········|········|········|········║·····000|········|········|········ = ········|·7······
NcChannels::BG_RGB_MASK: background in 3x8 RGB (rrggbb)
········|········|········|········║········|11111111|11111111|11111111 = ········|··FFFFFF
type in C: channels (uint64_t)
NcChannels
Mask Flags
Trait Implementations
If this bit is set, we are not using the default background color.
See the detailed diagram at NcChannels
Extract these bits to get the background NcAlpha
mask.
See the detailed diagram at NcChannels
If this bit and
BG_DEFAULT_MASK
are set, we’re using a palette-indexed background color.
See the detailed diagram at NcChannels
Extract these bits to get the background NcRgb
value.
New NcChannels
, set to black and using the “default color”.
New NcChannels
, expects two separate NcRgb
s for the foreground
and background channels.
New NcChannels
, expects a single NcRgb
for both foreground
and background channels.
fn from_rgb8(
fg_r: NcComponent,
fg_g: NcComponent,
fg_b: NcComponent,
bg_r: NcComponent,
bg_g: NcComponent,
bg_b: NcComponent
) -> Self
fn from_rgb8(
fg_r: NcComponent,
fg_g: NcComponent,
fg_b: NcComponent,
bg_r: NcComponent,
bg_g: NcComponent,
bg_b: NcComponent
) -> Self
New NcChannels
, expects three RGB NcComponent
components
for each channel.
New NcChannels
, expects three RGB NcComponent
components for
both the foreground and background channels.
fn from_rgb8_alpha(
fg_r: NcComponent,
fg_g: NcComponent,
fg_b: NcComponent,
fg_alpha: NcAlpha,
bg_r: NcComponent,
bg_g: NcComponent,
bg_b: NcComponent,
bg_alpha: NcAlpha
) -> Self
fn from_rgb8_alpha(
fg_r: NcComponent,
fg_g: NcComponent,
fg_b: NcComponent,
fg_alpha: NcAlpha,
bg_r: NcComponent,
bg_g: NcComponent,
bg_b: NcComponent,
bg_alpha: NcAlpha
) -> Self
New NcChannels
, expects three RGB NcComponent
s and
NcAlpha
, for both the foreground and background channels.
fn from_rgb8_alpha_both(
r: NcComponent,
g: NcComponent,
b: NcComponent,
alpha: NcAlpha
) -> Self
fn from_rgb8_alpha_both(
r: NcComponent,
g: NcComponent,
b: NcComponent,
alpha: NcAlpha
) -> Self
New NcChannel
, expects three RGB NcComponent
s.
Combines two NcChannel
s into an NcChannels
.
C style function: channels_combine().
Returns the NcChannels
with the fore- and background’s color
information swapped, but without touching housekeeping bits.
Alpha is retained unless it would lead to an illegal state:
HIGHCONTRAST
, TRANSPARENT
and BLEND
are taken to OPAQUE
unless the new value is RGB.
HIGHCONTRAST
TRANSPARENT
BLEND
OPAQUE
C style function: ncchannels_reverse().
Extracts the foreground NcChannel
.
C style function: ncchannels_fchannel().
Extracts the background NcChannel
.
C style function: ncchannels_bchannel().
Sets the foreground NcChannel
.
C style function: ncchannels_set_fchannel().
Sets the background NcChannel
.
C style function: ncchannels_set_bchannel().
Gets the foreground NcAlpha
.
C style function: ncchannels_fg_alpha().
Gets the background NcAlpha
.
C style function: ncchannels_bg_alpha().
Sets the foreground NcAlpha
.
C style function: ncchannels_set_fg_alpha().
Sets the background NcAlpha
.
C style function: ncchannels_set_bg_alpha().
Returns true if the foreground channel is set to RGB color.
C style function: ncchannels_fg_rgb_p().
Returns true if the background channel is set to RGB color.
C style function: ncchannels_bg_rgb_p().
Gets the foreground NcRgb
.
C style function: ncchannels_fg_rgb().
Gets the background NcRgb
.
C style function: ncchannels_bg_rgb().
Sets the foreground NcRgb
.
C style function: channels_set_fg_rgb().
Sets the background NcRgb
.
C style function: channels_set_bg_rgb().
Gets the three foreground RGB NcComponent
s (r, g, b).
C style function: channels_fg_rgb8().
Gets the three background RGB NcComponent
s (r, g, b).
C style function: channels_bg_rgb8().
Sets the three foreground RGB NcComponent
s (r, g, b), and
marks the foreground NcChannel
as not using the “default color”.
C style function: channels_set_fg_rgb8().
Sets the three background RGB NcComponent
s (r, g, b), and
marks the background NcChannel
as not using the “default color”.
C style function: channels_set_bg_rgb8().
Gets the foreground red NcComponent
.
(No equivalent C style function)
Gets the foreground green NcComponent
.
(No equivalent C style function)
Gets the foreground blue NcComponent
.
(No equivalent C style function)
Gets the background red NcComponent
.
(No equivalent C style function)
Gets the background green NcComponent
.
(No equivalent C style function)
Gets the background blue NcComponent
.
(No equivalent C style function)
Sets the foreground red NcComponent
, and returns the new NcChannels
.
(No equivalent C style function)
Sets the foreground green NcComponent
, and returns the new NcChannels
.
(No equivalent C style function)
Sets the foreground blue NcComponent
, and returns the new NcChannels
.
(No equivalent C style function)
Sets the background red NcComponent
, and returns the new NcChannels
.
(No equivalent C style function)
Sets the background green NcComponent
, and returns the new NcChannels
.
(No equivalent C style function)
Sets the background blue NcComponent
, and returns the new NcChannels
.
(No equivalent C style function)
Is the background using the “default background color”?
C style function: channels_fg_default_p().
Is the background using the “default background color”?
The “default background color” must generally be used to take advantage of terminal-effected transparency.
C style function: channels_bg_default_p().
Marks the foreground as using its “default color”, and
returns the new NcChannels
.
C style function: channels_set_fg_default().
Marks the background as using its “default color”, and
returns the new NcChannels
.
C style function: channels_set_bg_default().
Marks the foreground as NOT using its “default color”, and
returns the new NcChannels
.
C style function: channels_set_fg_default().
Marks the background as NOT using its “default color”, and
returns the new NcChannels
.
C style function: channels_set_bg_not_default().
Marks both the foreground and background as using its “default color”, and
returns the new NcChannels
.
Marks both the foreground and background as NOT using its “default color”,
and returns the new NcChannels
.
Extracts the NcPaletteIndex
from the foreground NcChannel
.
C style function: channels_fg_palindex().
Extracts the NcPaletteIndex
from the background NcChannel
.
C style function: channels_bg_palindex().
Is the foreground of using an indexed
NcPalette
color?
C style function: channels_fg_palindex_p().
Is the background of using an indexed
NcPalette
color?
C style function: channels_bg_palindex_p().
Sets the foreground of an NcChannels
as using an
indexed NcPalette
color.
C style function: channels_set_fg_palindex().
Sets the background of an NcChannels
as using an
indexed NcPalette
color.
C style function: channels_set_bg_palindex().
Does this glyph completely obscure the background? If so, there’s no need to emit a background when rasterizing, a small optimization. These are also used to track regions into which we must not cellblit.