Skip to main content

Color

Struct Color 

Source
pub struct Color<S: ColorSpace, E: Encoding> {
    pub ch: [Q0_16; 3],
    /* private fields */
}
Expand description

Three Q0_16 channels tagged with space and encoding.

Fields§

§ch: [Q0_16; 3]

Channel values.

Implementations§

Source§

impl<S: ColorSpace, E: Encoding> Color<S, E>

Source

pub const fn new(ch: [Q0_16; 3]) -> Self

Construct from three Q0_16 channels.

Source

pub const fn to_f32(self) -> ColorF32<S, E>

Convert channels to unit f32 (feature = "f32").

Source§

impl<S: ColorSpace> Color<S, Linear>

Source

pub const fn encode(self) -> Color<S, Encoded>

Encode with a same-space transfer. Numeric LUT apply is a later issue.

Source

pub const fn lerp(self, other: Self, t: Q0_16) -> Self

Linear interpolation between two linear colors of the same space.

t is Q0_16: 0 returns self, 65535 returns other.

Source§

impl<S: ColorSpace> Color<S, Encoded>

Source

pub const fn decode(self) -> Color<S, Linear>

Decode with a same-space transfer. Numeric LUT apply is a later issue.

Source§

impl<S: ColorSpace + Perceptual> Color<S, Encoded>

Source

pub const fn lerp(self, other: Self, t: Q0_16) -> Self

Interpolate encoded values only when the space is Perceptual.

Trait Implementations§

Source§

impl<S: ColorSpace, E: Encoding> Clone for Color<S, E>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: ColorSpace, E: Encoding> Copy for Color<S, E>

Source§

impl<S: ColorSpace, E: Encoding> Debug for Color<S, E>

Source§

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

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

impl<S: ColorSpace, E: Encoding> Eq for Color<S, E>

Source§

impl<S: ColorSpace, E: Encoding> From<Color<S, E>> for ColorF32<S, E>

Source§

fn from(color: Color<S, E>) -> Self

Converts to this type from the input type.
Source§

impl<S: ColorSpace, E: Encoding> From<ColorF32<S, E>> for Color<S, E>

Source§

fn from(color: ColorF32<S, E>) -> Self

Converts to this type from the input type.
Source§

impl<S: ColorSpace, E: Encoding> PartialEq for Color<S, E>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<S, E> Freeze for Color<S, E>
where PhantomData<fn() -> (S, E)>: Freeze,

§

impl<S, E> RefUnwindSafe for Color<S, E>

§

impl<S, E> Send for Color<S, E>
where PhantomData<fn() -> (S, E)>: Send,

§

impl<S, E> Sync for Color<S, E>
where PhantomData<fn() -> (S, E)>: Sync,

§

impl<S, E> Unpin for Color<S, E>
where PhantomData<fn() -> (S, E)>: Unpin,

§

impl<S, E> UnsafeUnpin for Color<S, E>

§

impl<S, E> UnwindSafe for Color<S, E>

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, 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.