Struct libnotcurses_sys::NcChannels
source · [−]#[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 = ········|··FFFFFF
type in C: channels (uint64_t)
NcChannels
Mask Flags
Tuple Fields
0: NcChannels_u64
Implementations
sourceimpl NcChannels
impl NcChannels
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.
sourceimpl NcChannels
impl NcChannels
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 NcRgb
s 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 NcChannel
s 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().
sourceimpl NcChannels
impl NcChannels
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
sourceimpl Binary for NcChannels
impl Binary for NcChannels
sourceimpl Clone for NcChannels
impl Clone for NcChannels
sourcefn clone(&self) -> NcChannels
fn clone(&self) -> NcChannels
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for NcChannels
impl Debug for NcChannels
sourceimpl Default for NcChannels
impl Default for NcChannels
sourceimpl Display for NcChannels
impl Display for NcChannels
sourceimpl From<&'_ NcChannels> for *const NcChannels_u64
impl From<&'_ NcChannels> for *const NcChannels_u64
sourcefn from(s: &NcChannels) -> Self
fn from(s: &NcChannels) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ mut NcChannels> for *mut NcChannels_u64
impl From<&'_ mut NcChannels> for *mut NcChannels_u64
sourcefn from(s: &mut NcChannels) -> Self
fn from(s: &mut NcChannels) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'a NcChannels> for &'a NcChannels_u64
impl<'a> From<&'a NcChannels> for &'a NcChannels_u64
sourcefn from(s: &'a NcChannels) -> Self
fn from(s: &'a NcChannels) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'a mut NcChannels> for &'a mut NcChannels_u64
impl<'a> From<&'a mut NcChannels> for &'a mut NcChannels_u64
sourcefn from(s: &'a mut NcChannels) -> Self
fn from(s: &'a mut NcChannels) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'a mut u64> for NcChannels
impl<'a> From<&'a mut u64> for NcChannels
sourcefn from(p: &'a mut NcChannels_u64) -> Self
fn from(p: &'a mut NcChannels_u64) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'a u64> for NcChannels
impl<'a> From<&'a u64> for NcChannels
sourcefn from(p: &'a NcChannels_u64) -> Self
fn from(p: &'a NcChannels_u64) -> Self
Converts to this type from the input type.
sourceimpl From<NcChannels> for NcChannels_u64
impl From<NcChannels> for NcChannels_u64
sourcefn from(s: NcChannels) -> Self
fn from(s: NcChannels) -> Self
Converts to this type from the input type.
sourceimpl From<NcChannels> for [u8; 6]
impl From<NcChannels> for [u8; 6]
sourcefn from(rgb: NcChannels) -> Self
fn from(rgb: NcChannels) -> Self
Converts to this type from the input type.
sourceimpl From<NcChannels> for (u8, u8, u8, u8, u8, u8)
impl From<NcChannels> for (u8, u8, u8, u8, u8, u8)
sourcefn from(rgb: NcChannels) -> Self
fn from(rgb: NcChannels) -> Self
Converts to this type from the input type.
sourceimpl From<u64> for NcChannels
impl From<u64> for NcChannels
sourcefn from(p: NcChannels_u64) -> Self
fn from(p: NcChannels_u64) -> Self
Converts to this type from the input type.
sourceimpl LowerHex for NcChannels
impl LowerHex for NcChannels
sourceimpl Octal for NcChannels
impl Octal for NcChannels
sourceimpl PartialEq<NcChannels> for NcChannels
impl PartialEq<NcChannels> for NcChannels
sourcefn eq(&self, other: &NcChannels) -> bool
fn eq(&self, other: &NcChannels) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &NcChannels) -> bool
fn ne(&self, other: &NcChannels) -> bool
This method tests for !=
.
sourceimpl UpperHex for NcChannels
impl UpperHex for NcChannels
impl Copy for NcChannels
impl StructuralPartialEq for NcChannels
Auto Trait Implementations
impl RefUnwindSafe for NcChannels
impl Send for NcChannels
impl Sync for NcChannels
impl Unpin for NcChannels
impl UnwindSafe for NcChannels
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more