#[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§
Source§impl NcChannel
§Constants
impl NcChannel
§Constants
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
§Constructors
impl NcChannel
§Constructors
Sourcepub fn with_default() -> Self
pub fn with_default() -> Self
New NcChannel, set to black and using the “default color”.
Source§impl NcChannel
§Methods
impl NcChannel
§Methods
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().