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 BBBBBBBB
type in C: channel (uint32_t)
See also
Tuple Fields§
§0: NcChannel_u32
Implementations§
source§impl NcChannel
impl NcChannel
sourcepub const DEFAULT_MASK: u32 = 1_073_741_824u32
pub const DEFAULT_MASK: u32 = 1_073_741_824u32
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 = 805_306_368u32
pub const ALPHA_MASK: u32 = 805_306_368u32
Extract these bits to get the (background) NcAlpha
mask.
Note: this is equivalent to
NcChannels::BG_ALPHA_MASK
sourcepub const PALETTE_MASK: u32 = 134_217_728u32
pub const PALETTE_MASK: u32 = 134_217_728u32
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 = 16_777_215u32
pub const RGB_MASK: u32 = 16_777_215u32
Extract these bits to get the background NcRgb
value.
Note: this is equivalent to
NcChannels::BG_RGB_MASK
source§impl NcChannel
impl NcChannel
sourcepub fn with_default() -> Self
pub fn with_default() -> Self
New NcChannel
, set to black and using the “default color”.
source§impl 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().