NcPixel

Struct NcPixel 

Source
pub struct NcPixel(pub NcPixel_u32);
Expand description

An ABGR pixel.

§Diagram

AAAAAAAA BBBBBBBB GGGGGGGG RRRRRRRR

NcPixel has 8 bits of alpha, more or less linear, contributing directly to the usual alpha blending equation.

We map the 8 bits of alpha to 2 bits of alpha via a level function

The NcPixel API facilitates direct management of the pixels within an NcVisual (NcVisuals keep a backing store of 32-bit RGBA pixels, and render them down to terminal graphics in NcVisual.render).

Per libav, we “store as BGRA on little-endian, and ARGB on big-endian”. This is an RGBA byte-order scheme. libav emits bytes, not words. Those bytes are R-G-B-A. When read as words, on little endian this will be ABGR, and on big-endian this will be RGBA. force everything to LE ABGR, a no-op on (and thus favoring) little-endian, which is the dominant ordering for processor architectures (x86, most ARM implementations, base RISC-V implementations) and their associated memory.

Tuple Fields§

§0: NcPixel_u32

Implementations§

Source§

impl NcPixel

Source

pub fn new(value: NcPixel_u32) -> Self

Returns a new NcPixel.

Source

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

Constructs a libav-compatible ABGR pixel from RGB components.

Source

pub fn from_rgba(rgba: impl Into<NcRgba>) -> Self

Constructs a libav-compatible ABGR pixel from RGBA components.

Source

pub fn to_rgb(&self) -> NcRgb

Converts to an RGB pixel.

Source

pub fn to_rgba(&self) -> NcRgba

Converts to an RGBA pixel.

Source

pub fn a(self) -> u8

Extracts the 8-bit alpha component from an ABGR pixel.

Source

pub fn b(self) -> u8

Extracts the 8 bit blue component from an ABGR pixel.

Source

pub fn g(self) -> u8

Extracts the 8 bit green component from an ABGR pixel.

Source

pub fn r(self) -> u8

Extracts the 8 bit red component from an ABGR pixel.

Source

pub fn set_a(&mut self, alpha: u8)

Sets the 8-bit alpha component of an ABGR pixel.

Source

pub fn set_g(&mut self, green: u8)

Sets the 8-bit green component of an ABGR pixel.

Source

pub fn set_b(&mut self, blue: u8)

Sets the 8-bit blue component of an ABGR pixel.

Source

pub fn set_r(&mut self, red: u8)

Sets the 8-bit red component of an ABGR pixel.

Source

pub fn set_rgb(&mut self, rgb: impl Into<NcRgb>)

Sets the RGB components of an ABGR pixel.

Trait Implementations§

Source§

impl Binary for NcPixel

Source§

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

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

impl Clone for NcPixel

Source§

fn clone(&self) -> NcPixel

Returns a duplicate 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 NcPixel

Source§

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

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

impl Default for NcPixel

Source§

fn default() -> NcPixel

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

impl Display for NcPixel

Source§

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

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

impl<'a> From<&'a NcPixel> for &'a NcPixel_u32

Source§

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

Converts to this type from the input type.
Source§

impl From<&NcPixel> for *const NcPixel_u32

Source§

fn from(s: &NcPixel) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut NcPixel> for &'a mut NcPixel_u32

Source§

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

Converts to this type from the input type.
Source§

impl From<&mut NcPixel> for *mut NcPixel_u32

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<NcPixel> for NcRgb

Source§

fn from(bgra: NcPixel) -> Self

Converts to this type from the input type.
Source§

impl From<NcPixel> for NcRgba

Source§

fn from(bgra: NcPixel) -> Self

Converts to this type from the input type.
Source§

impl From<NcPixel> for NcPixel_u32

Source§

fn from(s: NcPixel) -> Self

Converts to this type from the input type.
Source§

impl From<NcRgb> for NcPixel

Source§

fn from(rgb: NcRgb) -> Self

Converts to this type from the input type.
Source§

impl From<NcRgba> for NcPixel

Source§

fn from(rgba: NcRgba) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for NcPixel

Source§

fn from(p: NcPixel_u32) -> Self

Converts to this type from the input type.
Source§

impl LowerHex for NcPixel

Source§

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

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

impl Octal for NcPixel

Source§

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

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

impl PartialEq for NcPixel

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 UpperHex for NcPixel

Source§

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

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

impl Copy for NcPixel

Source§

impl Eq for NcPixel

Source§

impl StructuralPartialEq for NcPixel

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.