Skip to main content

NcChannel

Struct 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:

  • 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 = super::c_api::NC_BGDEFAULT_MASK

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 = super::c_api::NC_BG_ALPHA_MASK

Extract these bits to get the (background) NcAlpha mask.

Note: this is equivalent to NcChannels::BG_ALPHA_MASK

Source

pub const PALETTE_MASK: u32 = super::c_api::NC_BG_PALETTE

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 = super::c_api::NC_BG_RGB_MASK

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. Read more
Source§

impl Clone for NcChannel

Source§

fn clone(&self) -> NcChannel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for NcChannel

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 Eq for NcChannel

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<'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<'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<&NcChannel> for *const NcChannel_u32

Source§

fn from(s: &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 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<[u8; 3]> for NcChannel

Source§

fn from(array: [u8; 3]) -> 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. Read more
Source§

impl Octal for NcChannel

Source§

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

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

impl PartialEq for NcChannel

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for NcChannel

Source§

impl UpperHex for NcChannel

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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§

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>,

Source§

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>,

Source§

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.