Struct libnotcurses_sys::NcChannel
source · [−]#[repr(transparent)]pub struct NcChannel(pub NcChannel_u32);Expand description
32 bits of context-dependent info containing NcRgb + NcAlpha + extra
It is composed of:
The context details are documented in NcChannels
Diagram
~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBBtype in C: channel (uint32_t)
See also
Tuple Fields
0: NcChannel_u32Implementations
sourceimpl NcChannel
impl NcChannel
sourcepub const DEFAULT_MASK: u32
pub const DEFAULT_MASK: u32
If this bit is set, we are not using the default color.
Note: this is equivalent to
NcChannels::BG_DEFAULT_MASK
sourcepub const ALPHA_MASK: u32
pub const ALPHA_MASK: u32
Extract these bits to get the (background) NcAlpha mask.
Note: this is equivalent to
NcChannels::BG_ALPHA_MASK
sourcepub const PALETTE_MASK: u32
pub const PALETTE_MASK: u32
If this bit and
DEFAULT_MASK are set,
we’re using a palette-indexed background color
Note: this is equivalent to
NcChannels::BG_PALETTE_MASK
sourcepub const RGB_MASK: u32
pub const RGB_MASK: u32
Extract these bits to get the background NcRgb value.
Note: this is equivalent to
NcChannels::BG_RGB_MASK
sourceimpl NcChannel
impl NcChannel
sourcepub fn with_default() -> Self
pub fn with_default() -> Self
New NcChannel, set to black and using the “default color”.
sourceimpl NcChannel
impl NcChannel
sourcepub fn fcombine(&self, bchannel: impl Into<NcChannel>) -> NcChannels
pub fn fcombine(&self, bchannel: impl Into<NcChannel>) -> NcChannels
Combines this NcChannel as foreground, with another as background
into an NcChannels.
C style function: channels_combine().
sourcepub fn bcombine(&self, fchannel: impl Into<NcChannel>) -> NcChannels
pub fn bcombine(&self, fchannel: impl Into<NcChannel>) -> NcChannels
Combines this NcChannel as background, with another as foreground
into an NcChannels.
C style function: channels_combine().
sourcepub fn alpha(&self) -> NcAlpha
pub fn alpha(&self) -> NcAlpha
Gets the NcAlpha.
C style function: ncchannel_alpha().
sourcepub fn set_alpha(&mut self, alpha: impl Into<NcAlpha>) -> Self
pub fn set_alpha(&mut self, alpha: impl Into<NcAlpha>) -> Self
Sets the NcAlpha.
C style function: ncchannel_set_alpha().
sourcepub fn rgb_p(&self) -> bool
pub fn rgb_p(&self) -> bool
Returns true if the channel is set to RGB color.
C style function: ncchannel_rgb_p().
sourcepub fn rgb(&self) -> NcRgb
pub fn rgb(&self) -> NcRgb
Gets the NcRgb.
C style function: ncchannel_rgb().
sourcepub fn set(&mut self, rgb: impl Into<NcRgb>) -> Self
pub fn set(&mut self, rgb: impl Into<NcRgb>) -> Self
Sets the NcRgb, and marks the NcChannel as NOT using the
“default color”, retaining the other bits unchanged.
C style function: ncchannel_set().
sourcepub fn rgb8(&self) -> (u8, u8, u8)
pub fn rgb8(&self) -> (u8, u8, u8)
Gets the three components.
C style function: ncchannel_rgb8().
sourcepub fn set_rgb(&mut self, rgb: impl Into<NcRgb>) -> Self
pub fn set_rgb(&mut self, rgb: impl Into<NcRgb>) -> Self
Sets the three components, and marks the NcChannel as NOT using the “default color”.
C style function: ncchannel_set_rgb8().
sourcepub fn r(&self) -> u8
pub fn r(&self) -> u8
Gets the red component.
C style function: ncchannel_r().
sourcepub fn g(&self) -> u8
pub fn g(&self) -> u8
Gets the green component.
C style function: ncchannel_g().
sourcepub fn b(&self) -> u8
pub fn b(&self) -> u8
Gets the blue component.
C style function: ncchannel_b().
sourcepub fn set_r(&mut self, r: impl Into<u8>) -> Self
pub fn set_r(&mut self, r: impl Into<u8>) -> Self
Sets the red component, and returns the new NcChannel.
C style function: ncchannel_set_r().
sourcepub fn set_g(&mut self, g: impl Into<u8>) -> Self
pub fn set_g(&mut self, g: impl Into<u8>) -> Self
Sets the green component, and returns the new NcChannel.
C style function: ncchannel_set_g().
sourcepub fn set_b(&mut self, b: impl Into<u8>) -> Self
pub fn set_b(&mut self, b: impl Into<u8>) -> Self
Sets the blue component, and returns the new NcChannel.
C style function: ncchannel_set_b().
sourcepub fn default_p(&self) -> bool
pub fn default_p(&self) -> bool
Is this NcChannel using the “default color” rather than RGB/palette-indexed?
C style function: ncchannel_default_p().
sourcepub fn set_default(&mut self) -> Self
pub fn set_default(&mut self) -> Self
Marks this NcChannel as using its “default color”,
which also marks it opaque.
C style function: ncchannel_set_default().
sourcepub fn set_not_default(&mut self) -> Self
pub fn set_not_default(&mut self) -> Self
Marks this NcChannel as not using its “default color”.
The following methods also marks the channel as NOT using the “default color”:
C style function: ncchannel_set_not_default().
sourcepub fn palindex(&self) -> NcPaletteIndex
pub fn palindex(&self) -> NcPaletteIndex
Extracts the NcPaletteIndex from the NcChannel.
The channel must be palette-indexed, or the return value is meaningless.
Verify palette indexing with palindex_p.
C style function: ncchannel_palindex().
sourcepub fn palindex_p(&self) -> bool
pub fn palindex_p(&self) -> bool
Is this NcChannel using palette-indexed color rather a than RGB?
C style function: ncchannel_palindex_p().
sourcepub fn set_palindex(&mut self, index: impl Into<NcPaletteIndex>) -> Self
pub fn set_palindex(&mut self, index: impl Into<NcPaletteIndex>) -> Self
Sets the NcPaletteIndex of the NcChannel, and the channel into
palette-indexed mode.
C style function: ncchannel_set_palindex().
Trait Implementations
sourceimpl From<&'_ NcChannel> for *const NcChannel_u32
impl From<&'_ NcChannel> for *const NcChannel_u32
sourceimpl From<&'_ mut NcChannel> for *mut NcChannel_u32
impl From<&'_ mut NcChannel> for *mut NcChannel_u32
sourceimpl<'a> From<&'a NcChannel> for &'a NcChannel_u32
impl<'a> From<&'a NcChannel> for &'a NcChannel_u32
sourceimpl<'a> From<&'a mut NcChannel> for &'a mut NcChannel_u32
impl<'a> From<&'a mut NcChannel> for &'a mut NcChannel_u32
sourceimpl<'a> From<&'a mut u32> for NcChannel
impl<'a> From<&'a mut u32> for NcChannel
sourcefn from(p: &'a mut NcChannel_u32) -> Self
fn from(p: &'a mut NcChannel_u32) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'a u32> for NcChannel
impl<'a> From<&'a u32> for NcChannel
sourcefn from(p: &'a NcChannel_u32) -> Self
fn from(p: &'a NcChannel_u32) -> Self
Converts to this type from the input type.
sourceimpl From<NcChannel> for NcChannel_u32
impl From<NcChannel> for NcChannel_u32
sourceimpl From<u32> for NcChannel
impl From<u32> for NcChannel
sourcefn from(p: NcChannel_u32) -> Self
fn from(p: NcChannel_u32) -> Self
Converts to this type from the input type.
impl Copy for NcChannel
impl StructuralPartialEq for NcChannel
Auto Trait Implementations
impl RefUnwindSafe for NcChannel
impl Send for NcChannel
impl Sync for NcChannel
impl Unpin for NcChannel
impl UnwindSafe for NcChannel
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