Struct Luv

Source
#[repr(C)]
pub struct Luv<T, W> { /* private fields */ }
Expand description

The CIELUV perceptually uniform device-independent color space

Luv is a perceptually uniform color space introduced by CIE at the same time as Lab. Luv is especially well suited for dealing with colored lighting computations, with the additive mixture of two lights falling along a line in its the chromaticity space. It is an extension to the previous CIE UVW space.

Like Lab, Luv has a polar representation: Lchuv.

Implementations§

Source§

impl<T, W> Luv<T, W>

Source

pub fn new(L: T, u: T, v: T) -> Self

Construct a new Luv value with a named white point and channels.

Unlike new_with_whitepoint, new constructs a default instance of a UnitWhitePoint. It is only valid when W is a UnitWhitePoint.

Source§

impl<T, W> Luv<T, W>
where T: FreeChannelScalar, W: WhitePoint<T>,

Source

pub fn new_with_whitepoint(L: T, u: T, v: T, white_point: W) -> Self

Construct a new Luv value with a given white point and channels

Source

pub fn color_cast<TOut>(&self) -> Luv<TOut, W>
where T: ChannelFormatCast<TOut>, TOut: FreeChannelScalar,

Convert the internal channel scalar format

Source

pub fn L(&self) -> T

Returns the L lightness channel scalar

Source

pub fn u(&self) -> T

Returns the u green-red channel scalar

Source

pub fn v(&self) -> T

Returns the v blue-yellow channel scalar

Source

pub fn L_mut(&mut self) -> &mut T

Returns a mutable reference to the L lightness channel scalar

Source

pub fn u_mut(&mut self) -> &mut T

Returns a mutable reference to the u green-red channel scalar

Source

pub fn v_mut(&mut self) -> &mut T

Returns a mutable reference to the v blue-yellow channel scalar

Source

pub fn set_L(&mut self, val: T)

Set the L channel scalar

Source

pub fn set_u(&mut self, val: T)

Set the u channel scalar

Source

pub fn set_v(&mut self, val: T)

Set the v channel scalar

Source

pub fn white_point(&self) -> &W

Returns a reference to the white point for the Lab color space

Source§

impl<T, W> Luv<T, W>

Source

pub fn from_xyz(from: &Xyz<T>, wp: W) -> Self

Construct a Luv value from an Xyz value and white point

Source

pub fn to_xyz(&self) -> Xyz<T>

Construct an Xyz value from a Luv value

Source

pub fn epsilon() -> T

Return the $\epsilon$ constant used in the Lab conversion

For a description of the value, visit BruceLindbloom.com.

Source

pub fn kappa() -> T

Return the $\kappa$ constant used in the Lab conversion

For a description of the value, visit BruceLindbloom.com.

Trait Implementations§

Source§

impl<T, W> AbsDiffEq for Luv<T, W>

Source§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of ApproxEq::abs_diff_eq.
Source§

impl<T, W> Bounded for Luv<T, W>
where T: FreeChannelScalar, W: WhitePoint<T>,

Source§

fn normalize(self) -> Self

Return a value clipped inside the normalized range
Source§

fn is_normalized(&self) -> bool

Return true if the value is normalized
Source§

impl<T, W> Broadcast for Luv<T, W>

Source§

fn broadcast(value: T) -> Self

Construct Self with each channel set to value
Source§

impl<T: Clone, W: Clone> Clone for Luv<T, W>

Source§

fn clone(&self) -> Luv<T, W>

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<T, W> Color for Luv<T, W>
where T: FreeChannelScalar, W: WhitePoint<T>,

Source§

type Tag = LuvTag

The unique tag unit struct identifying the color type
Source§

type ChannelsTuple = (T, T, T)

A tuple of types for each channel in the color
Source§

fn num_channels() -> u32

Return how many channels the color has
Source§

fn to_tuple(self) -> Self::ChannelsTuple

Convert a color into a tuple of channels
Source§

impl<T: Debug, W: Debug> Debug for Luv<T, W>

Source§

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

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

impl<T, W> Default for Luv<T, W>

Source§

fn default() -> Self

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

impl<T, W> Display for Luv<T, W>

Source§

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

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

impl<T, W, A> FromColor<Lchuv<T, W, A>> for Luv<T, W>
where T: FreeChannelScalar, A: AngularChannelScalar + Angle<Scalar = T>, W: WhitePoint<T>,

Source§

fn from_color(from: &Lchuv<T, W, A>) -> Self

Construct a Lab value from an Lchuv value

Source§

impl<T, W, A> FromColor<Luv<T, W>> for Lchuv<T, W, A>

Source§

fn from_color(from: &Luv<T, W>) -> Self

Construct an Lchuv value from a Lab value

Source§

impl<T, W> FromTuple for Luv<T, W>

Source§

fn from_tuple(values: (T, T, T)) -> Self

Construct Self from a tuple of channel values
Source§

impl<T, W> HomogeneousColor for Luv<T, W>
where T: FreeChannelScalar, W: WhitePoint<T>,

Source§

type ChannelFormat = T

The scalar type of each channel
Source§

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

Clamp the value of each channel between min and max
Source§

impl<T, W> Lerp for Luv<T, W>
where T: FreeChannelScalar + Lerp, W: WhitePoint<T>,

Source§

type Position = <FreeChannel<T> as Lerp>::Position

The type of the pos argument
Source§

fn lerp(&self, right: &Self, pos: Self::Position) -> Self

Interpolate between self and right Read more
Source§

impl<T: PartialEq, W: PartialEq> PartialEq for Luv<T, W>

Source§

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

Source§

fn partial_cmp(&self, other: &Luv<T, W>) -> 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<T, W> RelativeEq for Luv<T, W>

Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of ApproxEq::relative_eq.
Source§

impl<T, W> UlpsEq for Luv<T, W>

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
Source§

impl<T: Copy, W: Copy> Copy for Luv<T, W>

Source§

impl<T, W> StructuralPartialEq for Luv<T, W>

Auto Trait Implementations§

§

impl<T, W> Freeze for Luv<T, W>
where W: Freeze, T: Freeze,

§

impl<T, W> RefUnwindSafe for Luv<T, W>

§

impl<T, W> Send for Luv<T, W>
where W: Send, T: Send,

§

impl<T, W> Sync for Luv<T, W>
where W: Sync, T: Sync,

§

impl<T, W> Unpin for Luv<T, W>
where W: Unpin, T: Unpin,

§

impl<T, W> UnwindSafe for Luv<T, W>
where W: UnwindSafe, T: UnwindSafe,

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.