#[repr(transparent)]
pub struct NcChannel(pub NcChannel_u32);
Expand description

32 bits of context-dependent info containing NcRgb + NcAlpha + extra

It is composed of:

  • a 24-bit NcRgb value
  • plus 8 bits divided in:
    • 2 bits of NcAlpha
    • 6 bits of context-dependent info

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

§Constants

source

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

source

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

source

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

source

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

source

pub fn new() -> Self

New NcChannel, set to black and NOT using the “default color”.

source

pub fn with_default() -> Self

New NcChannel, set to black and using the “default color”.

source

pub fn from_rgb(rgb: impl Into<NcRgb>) -> Self

New NcChannel, expects NcRgb.

source

pub fn from_rgb_alpha(rgb: impl Into<NcRgb>, alpha: NcAlpha) -> Self

New NcChannel, expects NcRgb & NcAlpha.

source§

impl NcChannel

§Methods

source

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().

source

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().

source

pub fn alpha(&self) -> NcAlpha

Gets the NcAlpha.

C style function: ncchannel_alpha().

source

pub fn set_alpha(&mut self, alpha: impl Into<NcAlpha>) -> Self

Sets the NcAlpha.

C style function: ncchannel_set_alpha().

source

pub fn rgb_p(&self) -> bool

Returns true if the channel is set to RGB color.

C style function: ncchannel_rgb_p().

source

pub fn rgb(&self) -> NcRgb

Gets the NcRgb.

C style function: ncchannel_rgb().

source

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().

source

pub fn rgb8(&self) -> (u8, u8, u8)

Gets the three components.

C style function: ncchannel_rgb8().

source

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().

source

pub fn r(&self) -> u8

Gets the red component.

C style function: ncchannel_r().

source

pub fn g(&self) -> u8

Gets the green component.

C style function: ncchannel_g().

source

pub fn b(&self) -> u8

Gets the blue component.

C style function: ncchannel_b().

source

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().

source

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().

source

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().

source

pub fn default_p(&self) -> bool

Is this NcChannel using the “default color” rather than RGB/palette-indexed?

C style function: ncchannel_default_p().

source

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().

source

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().

source

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().

source

pub fn palindex_p(&self) -> bool

Is this NcChannel using palette-indexed color rather a than RGB?

C style function: ncchannel_palindex_p().

source

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§

source§

impl Binary for NcChannel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Clone for NcChannel

source§

fn clone(&self) -> NcChannel

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NcChannel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for NcChannel

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for NcChannel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a NcChannel> for &'a NcChannel_u32

source§

fn from(s: &'a NcChannel) -> Self

Converts to this type from the input type.
source§

impl From<&NcChannel> for *const NcChannel_u32

source§

fn from(s: &NcChannel) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut NcChannel> for &'a mut NcChannel_u32

source§

fn from(s: &'a mut NcChannel) -> Self

Converts to this type from the input type.
source§

impl From<&mut NcChannel> for *mut NcChannel_u32

source§

fn from(s: &mut NcChannel) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut u32> for NcChannel

source§

fn from(p: &'a mut NcChannel_u32) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a u32> for NcChannel

source§

fn from(p: &'a NcChannel_u32) -> Self

Converts to this type from the input type.
source§

impl From<[u8; 3]> for NcChannel

source§

fn from(array: [u8; 3]) -> Self

Converts to this type from the input type.
source§

impl From<(u8, u8, u8)> for NcChannel

source§

fn from(tuple: (u8, u8, u8)) -> Self

Converts to this type from the input type.
source§

impl From<NcChannel> for [u8; 3]

source§

fn from(rgb: NcChannel) -> Self

Converts to this type from the input type.
source§

impl From<NcChannel> for (u8, u8, u8)

source§

fn from(rgb: NcChannel) -> Self

Converts to this type from the input type.
source§

impl From<NcChannel> for NcChannel_u32

source§

fn from(s: NcChannel) -> Self

Converts to this type from the input type.
source§

impl From<u32> for NcChannel

source§

fn from(p: NcChannel_u32) -> Self

Converts to this type from the input type.
source§

impl LowerHex for NcChannel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Octal for NcChannel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl PartialEq for NcChannel

source§

fn eq(&self, other: &NcChannel) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl UpperHex for NcChannel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Copy for NcChannel

source§

impl Eq for NcChannel

source§

impl StructuralPartialEq for NcChannel

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.