Srgba8

Struct Srgba8 

Source
pub struct Srgba8 {
    pub r: u8,
    pub g: u8,
    pub b: u8,
    pub a: u8,
}
Expand description

Non-linear sRGB+A color representation using 4 × u8 components.

Better suited for saving to the final graphics buffer.

Fields§

§r: u8

Gamma encoded red luminosity.

§g: u8

Gamma encoded green luminosity.

§b: u8

Gamma encoded blue luminosity.

§a: u8

Linear alpha channel.

Implementations§

Source§

impl Srgba8

Source

pub fn to_notcurses(&self) -> Rgba

Available on crate feature notcurses only.
Source§

impl Srgba8

§Constructors

Source

pub const fn new(r: u8, g: u8, b: u8, a: u8) -> Srgba8

New Srgba8.

Source§

impl Srgba8

§Direct conversions

Source

pub fn from_array(c: [u8; 4]) -> Srgba8

Direct conversion from an array.

Source

pub fn to_array(c: Srgba8) -> [u8; 4]

Direct conversion to an array.

Source

pub fn from_tuple(c: (u8, u8, u8, u8)) -> Srgba8

Direct conversion from a tuple.

Source

pub fn to_tuple(c: Srgba8) -> (u8, u8, u8, u8)

Direct conversion to a tuple.

Source

pub fn from_srgb8(c: Srgb8, alpha: u8) -> Srgba8

Direct conversion from Srgb8.

Adds the alpha channel.

Source

pub fn to_srgb8(&self) -> Srgb8

Direct conversion to Srgb8.

Loses the alpha channel.

Source

pub fn from_srgb32(c: Srgb32, alpha: u8) -> Srgba8

Direct conversion from Srgb32.

Adds the alpha channel.

Source

pub fn to_srgb32(&self) -> Srgb32

Direct conversion to Srgb32.

Loses the alpha channel.

Source

pub fn from_srgba32(c: Srgba32) -> Srgba8

Direct conversion from Srgba32.

Source

pub fn to_srgba32(&self) -> Srgba32

Direct conversion to Srgba32.

Source§

impl Srgba8

§Indirect conversions

Source

pub fn from_linear_srgb32(c: LinearSrgb32, alpha: u8) -> Srgba8

Available on crate features std or no_std only.

Indirect conversion from Srgb32.

Adds the alpha channel.

Source

pub fn to_linear_srgb32(&self) -> LinearSrgb32

Available on crate features std or no_std only.

Indirect conversion to LinearSrgb32.

Loses the alpha channel.

Source

pub fn from_linear_srgba32(c: LinearSrgba32) -> Srgba8

Available on crate features std or no_std only.

Indirect conversion from LinearSrgba32.

Source

pub fn to_linear_srgba32(&self) -> LinearSrgba32

Available on crate features std or no_std only.

Indirect conversion to LinearSrgba32.

Source

pub fn from_oklab32(c: Oklab32, alpha: u8) -> Srgba8

Available on crate features std or no_std only.

Indirect conversion from Oklab32.

Adds the alpha channel.

Source

pub fn to_oklab32(&self) -> Oklab32

Available on crate features std or no_std only.

Indirect conversion to Oklab32.

Loses the alpha channel.

Source

pub fn from_oklch32(c: Oklch32, alpha: u8) -> Srgba8

Available on crate features std or no_std only.

Indirect conversion from Oklch32.

Adds the alpha channel.

Source

pub fn to_oklch32(&self) -> Oklch32

Available on crate features std or no_std only.

Indirect conversion to Oklch32.

Loses the alpha channel.

Trait Implementations§

Source§

impl Clone for Srgba8

Source§

fn clone(&self) -> Srgba8

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 Color for Srgba8

Available on crate features std or no_std only.
Source§

fn color_red(&self) -> Self::Inner

Returns the gamma corrected red luminosity.

Source§

fn color_green(&self) -> Self::Inner

Returns the gamma corrected green luminosity.

Source§

fn color_blue(&self) -> Self::Inner

Returns the gamma corrected blue luminosity.

Source§

fn color_alpha(&self) -> Self::Inner

Returns the linear alpha.

Source§

fn color_to_srgba8(&self) -> Srgba8

no-op.

Source§

type Inner = u8

The type of the inner color components.
Source§

fn color_to_array3(&self) -> [Self::Inner; 3]

Returns the 3 components, without alpha.
Source§

fn color_to_array4(&self) -> [Self::Inner; 4]

Returns the 4 components, with alpha. Read more
Source§

fn color_luminosity(&self) -> Self::Inner

Returns the overall luminosity. Read more
Source§

fn color_hue(&self) -> Self::Inner

Returns the hue. Read more
Source§

fn color_to_srgb8(&self) -> Srgb8

Conversion to Srgb8.
Source§

fn color_to_srgb32(&self) -> Srgb32

Conversion to Srgb32.
Source§

fn color_to_srgba32(&self) -> Srgba32

Conversion to Srgba32.
Source§

fn color_to_linear_srgb32(&self) -> LinearSrgb32

Conversion to LinearSrgb32.
Source§

fn color_to_linear_srgba32(&self) -> LinearSrgba32

Conversion to LinearSrgba32.
Source§

fn color_to_oklab32(&self) -> Oklab32

Conversion to Oklab32.
Source§

fn color_to_oklch32(&self) -> Oklch32

Conversion to Oklch32.
Source§

impl Debug for Srgba8

Source§

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

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

impl Default for Srgba8

Source§

fn default() -> Srgba8

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

impl From<&Srgba8> for Rgba

Available on crate feature notcurses only.
Source§

fn from(c: &Srgba8) -> Rgba

Converts to this type from the input type.
Source§

impl From<Color> for Srgba8

Available on crate feature macroquad only.
Source§

impl From<Color> for Srgba8

Available on crate feature sdl2 only.
Source§

impl From<ColorU8> for Srgba8

Available on crate feature tiny-skia and (crate features std or no_std) only.
Source§

fn from(c: ColorU8) -> Srgba8

Converts to this type from the input type.
Source§

impl From<LinearSrgb32> for Srgba8

Available on crate features std or no_std only.
Source§

fn from(c: LinearSrgb32) -> Srgba8

Automatically adds alpha at max opacity.

Source§

impl From<LinearSrgba32> for Srgba8

Available on crate features std or no_std only.
Source§

fn from(c: LinearSrgba32) -> Srgba8

Converts to this type from the input type.
Source§

impl From<Oklab32> for Srgba8

Available on crate features std or no_std only.
Source§

fn from(c: Oklab32) -> Srgba8

Automatically adds alpha at max opacity.

Source§

impl From<PremultipliedColorU8> for Srgba8

Available on crate feature tiny-skia and (crate features std or no_std) only.
Source§

fn from(c: PmColorU8) -> Srgba8

Converts to this type from the input type.
Source§

impl From<Rgba<u8>> for Srgba8

Available on crate feature rgb only.

Convert rust-rgb’s RGBA<u8> type into Srgba8.

Source§

fn from(item: RGBA<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<Rgba> for Srgba8

Available on crate feature notcurses only.
Source§

fn from(c: Rgba) -> Srgba8

Converts to this type from the input type.
Source§

impl From<Srgb32> for Srgba8

Available on crate features std or no_std only.
Source§

fn from(c: Srgb32) -> Srgba8

Automatically adds alpha at max opacity.

Source§

impl From<Srgb8> for Srgba8

Available on crate features std or no_std only.
Source§

fn from(c: Srgb8) -> Srgba8

Automatically adds alpha at max opacity.

Source§

impl From<Srgba8> for Color

Available on crate feature macroquad only.
Source§

impl From<Srgba8> for Color

Available on crate feature sdl2 only.
Source§

impl From<Srgba8> for ColorU8

Available on crate feature tiny-skia and (crate features std or no_std) only.
Source§

fn from(c: Srgba8) -> ColorU8

Converts to this type from the input type.
Source§

impl From<Srgba8> for Oklab32

Available on crate features std or no_std only.
Source§

fn from(c: Srgba8) -> Oklab32

Converts to this type from the input type.
Source§

impl From<Srgba8> for Oklch32

Available on crate features std or no_std only.
Source§

fn from(c: Srgba8) -> Oklch32

Converts to this type from the input type.
Source§

impl From<Srgba8> for PremultipliedColorU8

Available on crate feature tiny-skia and (crate features std or no_std) only.
Source§

fn from(c: Srgba8) -> PmColorU8

Converts to this type from the input type.
Source§

impl From<Srgba8> for Rgba

Available on crate feature notcurses only.
Source§

fn from(c: Srgba8) -> Rgba

Converts to this type from the input type.
Source§

impl From<Srgba8> for RGBA<u8>

Available on crate feature rgb only.

Convert Srgba8 into rust-rgb’s RGBA<u8> type.

Source§

fn from(item: Srgba8) -> Self

Converts to this type from the input type.
Source§

impl From<Srgba8> for Srgb32

Available on crate features std or no_std only.
Source§

fn from(c: Srgba8) -> Srgb32

Converts to this type from the input type.
Source§

impl From<Srgba8> for Srgb8

Available on crate features std or no_std only.
Source§

fn from(c: Srgba8) -> Srgb8

Converts to this type from the input type.
Source§

impl From<Srgba8> for Srgba32

Available on crate features std or no_std only.
Source§

fn from(c: Srgba8) -> Srgba32

Converts to this type from the input type.
Source§

impl Ord for Srgba8

Source§

fn cmp(&self, other: &Srgba8) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Srgba8

Source§

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

Source§

fn partial_cmp(&self, other: &Srgba8) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToColor for Srgba8

Available on crate feature sdl2 only.
Source§

fn as_rgba(&self) -> (u8, u8, u8, u8)

Source§

fn as_u32(&self) -> u32

Source§

impl Copy for Srgba8

Source§

impl Eq for Srgba8

Source§

impl StructuralPartialEq for Srgba8

Auto Trait Implementations§

§

impl Freeze for Srgba8

§

impl RefUnwindSafe for Srgba8

§

impl Send for Srgba8

§

impl Sync for Srgba8

§

impl Unpin for Srgba8

§

impl UnwindSafe for Srgba8

Blanket Implementations§

Source§

impl<T> Also for T

Source§

fn also_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
Source§

fn also_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
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, Res> Apply<Res> for T
where T: ?Sized,

Source§

fn apply<F>(self, f: F) -> Res
where F: FnOnce(Self) -> Res, Self: Sized,

Apply a function which takes the parameter by value.
Source§

fn apply_ref<F>(&self, f: F) -> Res
where F: FnOnce(&Self) -> Res,

Apply a function which takes the parameter by shared reference.
Source§

fn apply_mut<F>(&mut self, f: F) -> Res
where F: FnOnce(&mut Self) -> Res,

Apply a function which takes the parameter by exclusive reference.
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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, 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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.