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.
source§

impl Clone for NcPixel

source§

fn clone(&self) -> NcPixel

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 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<'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<'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 *const NcPixel_u32

source§

fn from(s: &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 From<NcPixel> for NcPixel_u32

source§

fn from(s: NcPixel) -> 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<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.
source§

impl Octal for NcPixel

source§

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

Formats the value using the given formatter.
source§

impl PartialEq<NcPixel> for NcPixel

source§

fn eq(&self, other: &NcPixel) -> 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 NcPixel

source§

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

Formats the value using the given formatter.
source§

impl Copy for NcPixel

source§

impl Eq for NcPixel

source§

impl StructuralEq for NcPixel

source§

impl StructuralPartialEq for NcPixel

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.