Struct RGBA

Source
pub struct RGBA {
    pub red: u8,
    pub green: u8,
    pub blue: u8,
    pub alpha: u8,
}
Expand description

A color with red, green, blue, and alpha components, in a byte each.

Fields§

§red: u8

The red component.

§green: u8

The green component.

§blue: u8

The blue component.

§alpha: u8

The alpha component.

Implementations§

Source§

impl RGBA

Source

pub fn from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Self

Constructs a new RGBA value from float components. It expects the red, green, blue and alpha channels in that order, and all values will be clamped to the 0.0 … 1.0 range.

Source

pub fn transparent() -> Self

Returns a transparent color.

Source

pub fn new(red: u8, green: u8, blue: u8, alpha: f32) -> Self

Same thing, but with u8 values instead of floats in the 0 to 1 range.

Source

pub fn red_f32(&self) -> f32

Returns the red channel in a floating point number form, from 0 to 1.

Source

pub fn green_f32(&self) -> f32

Returns the green channel in a floating point number form, from 0 to 1.

Source

pub fn blue_f32(&self) -> f32

Returns the blue channel in a floating point number form, from 0 to 1.

Source

pub fn alpha_f32(&self) -> f32

Returns the alpha channel in a floating point number form, from 0 to 1.

Trait Implementations§

Source§

impl Clone for RGBA

Source§

fn clone(&self) -> RGBA

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 RGBA

Source§

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

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

impl From<&RGBA> for SRGB

Source§

fn from(rgb: &RGBA) -> SRGB

Converts to this type from the input type.
Source§

impl From<A98> for RGBA

Source§

fn from(t: A98) -> RGBA

Converts to this type from the input type.
Source§

impl From<FloatColor> for RGBA

Source§

fn from(color: FloatColor) -> RGBA

Converts to this type from the input type.
Source§

impl From<HSL> for RGBA

Source§

fn from(t: HSL) -> RGBA

Converts to this type from the input type.
Source§

impl From<HWB> for RGBA

Source§

fn from(t: HWB) -> RGBA

Converts to this type from the input type.
Source§

impl From<LAB> for RGBA

Source§

fn from(t: LAB) -> RGBA

Converts to this type from the input type.
Source§

impl From<LABColor> for RGBA

Source§

fn from(color: LABColor) -> RGBA

Converts to this type from the input type.
Source§

impl From<LCH> for RGBA

Source§

fn from(t: LCH) -> RGBA

Converts to this type from the input type.
Source§

impl From<OKLAB> for RGBA

Source§

fn from(t: OKLAB) -> RGBA

Converts to this type from the input type.
Source§

impl From<OKLCH> for RGBA

Source§

fn from(t: OKLCH) -> RGBA

Converts to this type from the input type.
Source§

impl From<P3> for RGBA

Source§

fn from(t: P3) -> RGBA

Converts to this type from the input type.
Source§

impl From<PredefinedColor> for RGBA

Source§

fn from(color: PredefinedColor) -> RGBA

Converts to this type from the input type.
Source§

impl From<ProPhoto> for RGBA

Source§

fn from(t: ProPhoto) -> RGBA

Converts to this type from the input type.
Source§

impl From<RGBA> for A98

Source§

fn from(t: RGBA) -> A98

Converts to this type from the input type.
Source§

impl From<RGBA> for CssColor

Source§

fn from(color: RGBA) -> CssColor

Converts to this type from the input type.
Source§

impl From<RGBA> for HSL

Source§

fn from(t: RGBA) -> HSL

Converts to this type from the input type.
Source§

impl From<RGBA> for HWB

Source§

fn from(t: RGBA) -> HWB

Converts to this type from the input type.
Source§

impl From<RGBA> for LAB

Source§

fn from(t: RGBA) -> LAB

Converts to this type from the input type.
Source§

impl From<RGBA> for LCH

Source§

fn from(t: RGBA) -> LCH

Converts to this type from the input type.
Source§

impl From<RGBA> for OKLAB

Source§

fn from(t: RGBA) -> OKLAB

Converts to this type from the input type.
Source§

impl From<RGBA> for OKLCH

Source§

fn from(t: RGBA) -> OKLCH

Converts to this type from the input type.
Source§

impl From<RGBA> for P3

Source§

fn from(t: RGBA) -> P3

Converts to this type from the input type.
Source§

impl From<RGBA> for ProPhoto

Source§

fn from(t: RGBA) -> ProPhoto

Converts to this type from the input type.
Source§

impl From<RGBA> for Rec2020

Source§

fn from(t: RGBA) -> Rec2020

Converts to this type from the input type.
Source§

impl From<RGBA> for SRGB

Source§

fn from(rgb: RGBA) -> Self

Converts to this type from the input type.
Source§

impl From<RGBA> for SRGBLinear

Source§

fn from(t: RGBA) -> SRGBLinear

Converts to this type from the input type.
Source§

impl From<RGBA> for XYZd50

Source§

fn from(t: RGBA) -> XYZd50

Converts to this type from the input type.
Source§

impl From<RGBA> for XYZd65

Source§

fn from(t: RGBA) -> XYZd65

Converts to this type from the input type.
Source§

impl From<Rec2020> for RGBA

Source§

fn from(t: Rec2020) -> RGBA

Converts to this type from the input type.
Source§

impl From<SRGB> for RGBA

Source§

fn from(rgb: SRGB) -> RGBA

Converts to this type from the input type.
Source§

impl From<SRGBLinear> for RGBA

Source§

fn from(t: SRGBLinear) -> RGBA

Converts to this type from the input type.
Source§

impl From<XYZd50> for RGBA

Source§

fn from(t: XYZd50) -> RGBA

Converts to this type from the input type.
Source§

impl From<XYZd65> for RGBA

Source§

fn from(t: XYZd65) -> RGBA

Converts to this type from the input type.
Source§

impl PartialEq for RGBA

Source§

fn eq(&self, other: &RGBA) -> 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 TryFrom<&CssColor> for RGBA

Source§

type Error = ()

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

fn try_from(color: &CssColor) -> Result<RGBA, ()>

Performs the conversion.
Source§

impl TryFrom<CssColor> for RGBA

Source§

type Error = ()

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

fn try_from(color: CssColor) -> Result<RGBA, ()>

Performs the conversion.
Source§

impl<'i, V: ?Sized + Visitor<'i, T>, T: Visit<'i, T, V>> Visit<'i, T, V> for RGBA

Available on crate feature visitor only.
Source§

const CHILD_TYPES: VisitTypes

The types of values contained within this value and its children. This is used to skip branches that don’t have any values requested by the Visitor.
Source§

fn visit_children(&mut self, _: &mut V) -> Result<(), V::Error>

Visit the children of this value.
Source§

fn visit(&mut self, visitor: &mut V) -> Result<(), V::Error>

Visits the value by calling an appropriate method on the Visitor. If no corresponding visitor method exists, then the children are visited.
Source§

impl Copy for RGBA

Source§

impl StructuralPartialEq for RGBA

Auto Trait Implementations§

§

impl Freeze for RGBA

§

impl RefUnwindSafe for RGBA

§

impl Send for RGBA

§

impl Sync for RGBA

§

impl Unpin for RGBA

§

impl UnwindSafe for RGBA

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.