#[repr(transparent)]pub struct NcChannels(pub NcChannels_u64);Expand description
64 bits containing a foreground and background NcChannel
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 = ········|··FFFFFFtype in C: channels (uint64_t)
§NcChannels Mask Flags
Tuple Fields§
§0: NcChannels_u64Implementations§
Source§impl NcChannels
§NcChannels constants
impl NcChannels
§NcChannels constants
Sourcepub const BG_DEFAULT_MASK: u32 = 1_073_741_824u32
pub const BG_DEFAULT_MASK: u32 = 1_073_741_824u32
If this bit is set, we are not using the default background color.
See the detailed diagram at NcChannels
Sourcepub const BG_ALPHA_MASK: u32 = 805_306_368u32
pub const BG_ALPHA_MASK: u32 = 805_306_368u32
Extract these bits to get the background NcAlpha mask.
See the detailed diagram at NcChannels
Sourcepub const BG_PALETTE_MASK: u32 = 134_217_728u32
pub const BG_PALETTE_MASK: u32 = 134_217_728u32
If this bit and
BG_DEFAULT_MASK
are set, we’re using a palette-indexed background color.
See the detailed diagram at NcChannels
Sourcepub const BG_RGB_MASK: u32 = 16_777_215u32
pub const BG_RGB_MASK: u32 = 16_777_215u32
Extract these bits to get the background NcRgb value.
Sourcepub const NOBACKGROUND_MASK: u64 = 9_727_775_195_120_271_360u64
pub const NOBACKGROUND_MASK: u64 = 9_727_775_195_120_271_360u64
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.
Source§impl NcChannels
§NcChannels constructors
impl NcChannels
§NcChannels constructors
Sourcepub fn with_default() -> Self
pub fn with_default() -> Self
New NcChannels, set to black and using the “default color”.
Sourcepub fn from_rgb(fg_rgb: impl Into<NcRgb>, bg_rgb: impl Into<NcRgb>) -> Self
pub fn from_rgb(fg_rgb: impl Into<NcRgb>, bg_rgb: impl Into<NcRgb>) -> Self
New NcChannels, expects two separate NcRgbs for the foreground
and background channels.
Sourcepub fn from_rgb_both(rgb: impl Into<NcRgb>) -> Self
pub fn from_rgb_both(rgb: impl Into<NcRgb>) -> Self
New NcChannels, expects a single NcRgb for both foreground
and background channels.
Sourcepub fn from_rgb_alpha(
fg_rgb: impl Into<NcRgb>,
fg_alpha: impl Into<NcAlpha>,
bg_rgb: impl Into<NcRgb>,
bg_alpha: impl Into<NcAlpha>,
) -> Self
pub fn from_rgb_alpha( fg_rgb: impl Into<NcRgb>, fg_alpha: impl Into<NcAlpha>, bg_rgb: impl Into<NcRgb>, bg_alpha: impl Into<NcAlpha>, ) -> Self
Sourcepub fn combine(
fchannel: impl Into<NcChannel>,
bchannel: impl Into<NcChannel>,
) -> Self
pub fn combine( fchannel: impl Into<NcChannel>, bchannel: impl Into<NcChannel>, ) -> Self
Combines two NcChannels into an NcChannels.
C style function: channels_combine().
Sourcepub fn reverse(&mut self) -> Self
pub fn reverse(&mut self) -> Self
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().
Source§impl NcChannels
§NcChannels methods
impl NcChannels
§NcChannels methods
Sourcepub fn fchannel(&self) -> NcChannel
pub fn fchannel(&self) -> NcChannel
Gets the foreground alpha and coloring bits as an NcChannel.
C style function: ncchannels_fchannel().
Sourcepub fn bchannel(&self) -> NcChannel
pub fn bchannel(&self) -> NcChannel
Gets the background alpha and coloring bits as an NcChannel.
C style function: ncchannels_bchannel().
Sourcepub fn set_fchannel(&mut self, fchannel: impl Into<NcChannel>) -> Self
pub fn set_fchannel(&mut self, fchannel: impl Into<NcChannel>) -> Self
Sets the foreground alpha and coloring bits from an NcChannel.
C style function: ncchannels_set_fchannel().
Sourcepub fn set_bchannel(&mut self, bchannel: impl Into<NcChannel>) -> Self
pub fn set_bchannel(&mut self, bchannel: impl Into<NcChannel>) -> Self
Sets the background alpha and coloring bits from an NcChannel.
C style function: ncchannels_set_bchannel().
Sourcepub fn channels(&self) -> NcChannels
pub fn channels(&self) -> NcChannels
Gets the alpha and coloring bits as an NcChannels.
C style function: ncchannels_bchannel().
Sourcepub fn set_channels(&mut self, from_channels: impl Into<NcChannels>) -> Self
pub fn set_channels(&mut self, from_channels: impl Into<NcChannels>) -> Self
Sets the foreground alpha and coloring bits as an NcChannels,
from another NcChannels.
C style function: ncchannels_set_fchannel().
Sourcepub fn fg_alpha(&self) -> NcAlpha
pub fn fg_alpha(&self) -> NcAlpha
Gets the foreground NcAlpha.
C style function: ncchannels_fg_alpha().
Sourcepub fn bg_alpha(&self) -> NcAlpha
pub fn bg_alpha(&self) -> NcAlpha
Gets the background NcAlpha.
C style function: ncchannels_bg_alpha().
Sourcepub fn set_fg_alpha(&mut self, alpha: impl Into<NcAlpha>) -> NcResult<()>
pub fn set_fg_alpha(&mut self, alpha: impl Into<NcAlpha>) -> NcResult<()>
Sets the foreground NcAlpha.
C style function: ncchannels_set_fg_alpha().
Sourcepub fn set_bg_alpha(&mut self, alpha: impl Into<NcAlpha>) -> NcResult<()>
pub fn set_bg_alpha(&mut self, alpha: impl Into<NcAlpha>) -> NcResult<()>
Sets the background NcAlpha.
C style function: ncchannels_set_bg_alpha().
Sourcepub fn fg_rgb_p(&self) -> bool
pub fn fg_rgb_p(&self) -> bool
Returns true if the foreground channel is set to RGB color.
C style function: ncchannels_fg_rgb_p().
Sourcepub fn bg_rgb_p(&self) -> bool
pub fn bg_rgb_p(&self) -> bool
Returns true if the background channel is set to RGB color.
C style function: ncchannels_bg_rgb_p().
Sourcepub fn fg_rgb(&self) -> NcRgb
pub fn fg_rgb(&self) -> NcRgb
Gets the foreground NcRgb.
C style function: ncchannels_fg_rgb().
Sourcepub fn bg_rgb(&self) -> NcRgb
pub fn bg_rgb(&self) -> NcRgb
Gets the background NcRgb.
C style function: ncchannels_bg_rgb().
Sourcepub fn set_fg_rgb(&mut self, rgb: impl Into<NcRgb>) -> Self
pub fn set_fg_rgb(&mut self, rgb: impl Into<NcRgb>) -> Self
Sets the foreground NcRgb.
C style function: channels_set_fg_rgb().
Sourcepub fn set_bg_rgb(&mut self, rgb: impl Into<NcRgb>) -> Self
pub fn set_bg_rgb(&mut self, rgb: impl Into<NcRgb>) -> Self
Sets the background NcRgb.
C style function: channels_set_bg_rgb().
Sourcepub fn fg_set_r(&mut self, r: impl Into<u8>) -> Self
pub fn fg_set_r(&mut self, r: impl Into<u8>) -> Self
Sets the foreground red component, and returns the new NcChannels.
(No equivalent C style function)
Sourcepub fn fg_set_g(&mut self, g: impl Into<u8>) -> Self
pub fn fg_set_g(&mut self, g: impl Into<u8>) -> Self
Sets the foreground green component, and returns the new NcChannels.
(No equivalent C style function)
Sourcepub fn fg_set_b(&mut self, b: impl Into<u8>) -> Self
pub fn fg_set_b(&mut self, b: impl Into<u8>) -> Self
Sets the foreground blue component, and returns the new NcChannels.
(No equivalent C style function)
Sourcepub fn bg_set_r(&mut self, r: impl Into<u8>) -> Self
pub fn bg_set_r(&mut self, r: impl Into<u8>) -> Self
Sets the background red component, and returns the new NcChannels.
(No equivalent C style function)
Sourcepub fn bg_set_g(&mut self, g: impl Into<u8>) -> Self
pub fn bg_set_g(&mut self, g: impl Into<u8>) -> Self
Sets the background green component, and returns the new NcChannels.
(No equivalent C style function)
Sourcepub fn bg_set_b(&mut self, b: impl Into<u8>) -> Self
pub fn bg_set_b(&mut self, b: impl Into<u8>) -> Self
Sets the background blue component, and returns the new NcChannels.
(No equivalent C style function)
Sourcepub fn fg_default_p(&self) -> bool
pub fn fg_default_p(&self) -> bool
Is the background using the “default background color”?
C style function: channels_fg_default_p().
Sourcepub fn bg_default_p(&self) -> bool
pub fn bg_default_p(&self) -> bool
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().
Sourcepub fn set_fg_default(&mut self) -> Self
pub fn set_fg_default(&mut self) -> Self
Marks the foreground as using its “default color”, and
returns the new NcChannels.
C style function: channels_set_fg_default().
Sourcepub fn set_bg_default(&mut self) -> Self
pub fn set_bg_default(&mut self) -> Self
Marks the background as using its “default color”, and
returns the new NcChannels.
C style function: channels_set_bg_default().
Sourcepub fn set_fg_not_default(&mut self) -> Self
pub fn set_fg_not_default(&mut self) -> Self
Marks the foreground as NOT using its “default color”, and
returns the new NcChannels.
C style function: channels_set_fg_default().
Sourcepub fn set_bg_not_default(&mut self) -> Self
pub fn set_bg_not_default(&mut self) -> Self
Marks the background as NOT using its “default color”, and
returns the new NcChannels.
C style function: channels_set_bg_not_default().
Sourcepub fn set_default(&mut self) -> Self
pub fn set_default(&mut self) -> Self
Marks both the foreground and background as using its “default color”, and
returns the new NcChannels.
Sourcepub fn set_not_default(&mut self) -> Self
pub fn set_not_default(&mut self) -> Self
Marks both the foreground and background as NOT using its “default color”,
and returns the new NcChannels.
Sourcepub fn fg_palindex(&self) -> NcPaletteIndex
pub fn fg_palindex(&self) -> NcPaletteIndex
Gets the NcPaletteIndex from the foreground NcChannel.
C style function: channels_fg_palindex().
Sourcepub fn bg_palindex(&self) -> NcPaletteIndex
pub fn bg_palindex(&self) -> NcPaletteIndex
Gets the NcPaletteIndex from the background NcChannel.
C style function: channels_bg_palindex().
Sourcepub fn fg_palindex_p(&self) -> bool
pub fn fg_palindex_p(&self) -> bool
Is the foreground of using an indexed
NcPalette color?
C style function: channels_fg_palindex_p().
Sourcepub fn bg_palindex_p(&self) -> bool
pub fn bg_palindex_p(&self) -> bool
Is the background of using an indexed
NcPalette color?
C style function: channels_bg_palindex_p().
Sourcepub fn set_fg_palindex(&mut self, index: impl Into<NcPaletteIndex>) -> Self
pub fn set_fg_palindex(&mut self, index: impl Into<NcPaletteIndex>) -> Self
Sets the foreground of an NcChannels as using an
indexed NcPalette color.
C style function: channels_set_fg_palindex().
Sourcepub fn set_bg_palindex(&mut self, index: impl Into<NcPaletteIndex>) -> Self
pub fn set_bg_palindex(&mut self, index: impl Into<NcPaletteIndex>) -> Self
Sets the background of an NcChannels as using an
indexed NcPalette color.
C style function: channels_set_bg_palindex().
Trait Implementations§
Source§impl Binary for NcChannels
impl Binary for NcChannels
Source§impl Clone for NcChannels
impl Clone for NcChannels
Source§fn clone(&self) -> NcChannels
fn clone(&self) -> NcChannels
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more