Struct deltae::DeltaE

source ·
pub struct DeltaE { /* private fields */ }
Expand description

§The measured difference between two colors

There are many different methods of calculating color difference. Different methods have a specific purpose, mainly in determining the level of tolerance for describing the difference between two colors. Regardless of the DEMethod used, DeltaE is always calculated based on the LabValues of the two colors.

Implementations§

source§

impl DeltaE

source

pub fn new<A, B>(a: A, b: B, method: DEMethod) -> DeltaE
where A: Delta, B: Delta,

New DeltaE from two colors and a DEMethod.

use deltae::{LabValue, DeltaE, DEMethod::DE2000};

let lab0 = LabValue::new(89.73, 1.88, -6.96).unwrap();
let lab1 = LabValue::new(95.08, -0.17, -10.81).unwrap();
let de0 = DeltaE::new(&lab0, &lab1, DE2000);
assert_eq!(de0, 5.316941);
source

pub fn with_method(self, method: DEMethod) -> Self

Recalculate DeltaE with another DEMethod

use deltae::{Delta, DeltaE, LabValue, DEMethod};

let lab0 = LabValue::new(89.73, 1.88, -6.96).unwrap();
let lab1 = LabValue::new(95.08, -0.17, -10.81).unwrap();
let de2000 = lab0.delta(lab1, DEMethod::DE2000);
let de1976 = de2000.with_method(DEMethod::DE1976);
assert_eq!(de1976, 6.902716);
source

pub fn method(&self) -> &DEMethod

Return a reference to the DeltaE method used in the calculation

source

pub fn value(&self) -> &f32

Return a reference to the DeltaE value

source

pub fn reference(&self) -> &LabValue

Return a reference to the reference LabValue used in the calculation. A reference color is the base color to which the sample color is being compared.

source

pub fn sample(&self) -> &LabValue

Return a reference to the sample LabValue used in the calculation. A sample color is the color being compared to the reference color.

Trait Implementations§

source§

impl Clone for DeltaE

source§

fn clone(&self) -> DeltaE

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 DeltaE

source§

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

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

impl Display for DeltaE

source§

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

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

impl PartialEq<f32> for DeltaE

source§

fn eq(&self, f: &f32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for DeltaE

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for DeltaE

One should be careful when ordering DeltaE. A DE2000:1.0 value is not necessarily the same amount of color difference as a amount of color difference DE1976:1.0 value.

source§

fn partial_cmp(&self, other: &Self) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Round for DeltaE

source§

fn round_to(self, places: i32) -> Self

Rounds the value to a number of decimal places
source§

impl Tolerance for DeltaE

source§

fn tolerance(self) -> f32

Return a tolerance value
source§

impl Copy for DeltaE

Auto Trait Implementations§

§

impl Freeze for DeltaE

§

impl RefUnwindSafe for DeltaE

§

impl Send for DeltaE

§

impl Sync for DeltaE

§

impl Unpin for DeltaE

§

impl UnwindSafe for DeltaE

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

§

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§

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

§

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

§

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.