[go: up one dir, main page]

SrgbaTuple

Struct SrgbaTuple 

Source
pub struct SrgbaTuple(pub f32, pub f32, pub f32, pub f32);
Expand description

A pixel value encoded as SRGBA RGBA values in f32 format (range: 0.0-1.0)

Tuple Fields§

§0: f32§1: f32§2: f32§3: f32

Implementations§

Source§

impl SrgbaTuple

Source

pub fn premultiply(self) -> SrgbaTuple

Source

pub fn demultiply(self) -> SrgbaTuple

Source

pub fn to_tuple_rgba(self) -> (f32, f32, f32, f32)

Source

pub fn as_rgba_u8(self) -> (u8, u8, u8, u8)

Source

pub fn interpolate(self, other: SrgbaTuple, k: f64) -> SrgbaTuple

Source§

impl SrgbaTuple

Source

pub fn from_named(name: &str) -> Option<SrgbaTuple>

Construct a color from an X11/SVG/CSS3 color name. Returns None if the supplied name is not recognized. The list of names can be found here: https://en.wikipedia.org/wiki/X11_color_names

Source

pub fn mul_alpha(self, alpha: f32) -> SrgbaTuple

Returns self multiplied by the supplied alpha value. We don’t need to linearize for this, as alpha is defined as being linear even in srgba!

Source

pub fn to_linear(self) -> LinearRgba

Source

pub fn to_srgb_u8(self) -> (u8, u8, u8, u8)

Source

pub fn to_string(self) -> String

Source

pub fn to_rgb_string(self) -> String

Returns a string of the form #RRGGBB

Source

pub fn to_rgba_string(self) -> String

Source

pub fn to_x11_16bit_rgb_string(self) -> String

Returns a string of the form rgb:RRRR/GGGG/BBBB

Source

pub fn to_laba(self) -> (f64, f64, f64, f64)

Source

pub fn to_hsla(self) -> (f64, f64, f64, f64)

Source

pub fn from_hsla(h: f64, s: f64, l: f64, a: f64) -> SrgbaTuple

Source

pub fn saturate(&self, factor: f64) -> SrgbaTuple

Scale the color towards the maximum saturation by factor, a value ranging from 0.0 to 1.0.

Source

pub fn saturate_fixed(&self, amount: f64) -> SrgbaTuple

Increase the saturation by amount, a value ranging from 0.0 to 1.0.

Source

pub fn lighten(&self, factor: f64) -> SrgbaTuple

Scale the color towards the maximum lightness by factor, a value ranging from 0.0 to 1.0

Source

pub fn lighten_fixed(&self, amount: f64) -> SrgbaTuple

Lighten the color by amount, a value ranging from 0.0 to 1.0

Source

pub fn adjust_hue_fixed(&self, amount: f64) -> SrgbaTuple

Rotate the hue angle by the specified number of degrees

Source

pub fn complement(&self) -> SrgbaTuple

Source

pub fn complement_ryb(&self) -> SrgbaTuple

Source

pub fn triad(&self) -> (SrgbaTuple, SrgbaTuple)

Source

pub fn square(&self) -> (SrgbaTuple, SrgbaTuple, SrgbaTuple)

Source

pub fn adjust_hue_fixed_ryb(&self, amount: f64) -> SrgbaTuple

Rotate the hue angle by the specified number of degrees, using the RYB color wheel

Source

pub fn delta_e(&self, other: &SrgbaTuple) -> f32

Source

pub fn contrast_ratio(&self, other: &SrgbaTuple) -> f64

Trait Implementations§

Source§

impl Clone for SrgbaTuple

Source§

fn clone(&self) -> SrgbaTuple

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 SrgbaTuple

Source§

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

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

impl Default for SrgbaTuple

Source§

fn default() -> SrgbaTuple

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

impl<'de> Deserialize<'de> for SrgbaTuple

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<SrgbaTuple, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<(f32, f32, f32, f32)> for SrgbaTuple

Source§

fn from(_: (f32, f32, f32, f32)) -> SrgbaTuple

Converts to this type from the input type.
Source§

impl From<(u8, u8, u8)> for SrgbaTuple

Source§

fn from(_: (u8, u8, u8)) -> SrgbaTuple

Converts to this type from the input type.
Source§

impl From<(u8, u8, u8, u8)> for SrgbaTuple

Source§

fn from(_: (u8, u8, u8, u8)) -> SrgbaTuple

Converts to this type from the input type.
Source§

impl From<Color> for SrgbaTuple

Source§

fn from(color: Color) -> SrgbaTuple

Converts to this type from the input type.
Source§

impl From<SrgbaPixel> for SrgbaTuple

Source§

fn from(pixel: SrgbaPixel) -> SrgbaTuple

Converts to this type from the input type.
Source§

impl From<SrgbaTuple> for ColorSpec

Source§

fn from(col: SrgbaTuple) -> Self

Converts to this type from the input type.
Source§

impl From<SrgbaTuple> for RgbColor

Source§

fn from(srgb: SrgbaTuple) -> RgbColor

Converts to this type from the input type.
Source§

impl FromDynamic for SrgbaTuple

Source§

impl FromStr for SrgbaTuple

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<SrgbaTuple, <SrgbaTuple as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for SrgbaTuple

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Into<SrgbaTuple> for RgbColor

Source§

fn into(self) -> SrgbaTuple

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for SrgbaTuple

Source§

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

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToDynamic for SrgbaTuple

Source§

impl Copy for SrgbaTuple

Source§

impl Eq for SrgbaTuple

Source§

impl StructuralPartialEq for SrgbaTuple

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

Source§

type Output = T

Should always be 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,