Trait palette::color_difference::EuclideanDistance
source · pub trait EuclideanDistance: Sized {
type Scalar;
// Required method
fn distance_squared(self, other: Self) -> Self::Scalar;
// Provided method
fn distance(self, other: Self) -> Self::Scalar
where Self::Scalar: Sqrt { ... }
}
Expand description
Calculate the distance between two colors as if they were coordinates in Euclidean space.
Euclidean distance is not always a good measurement of visual color
difference, depending on the color space. Some spaces, like Lab
and
Oklab
, will give a fairly uniform result, while other
spaces, such as Rgb
, will give much less uniform
results. Despite that, it’s still appropriate for some applications.
Required Associated Types§
Required Methods§
sourcefn distance_squared(self, other: Self) -> Self::Scalar
fn distance_squared(self, other: Self) -> Self::Scalar
Calculate the squared Euclidean distance from self
to other
.
This is typically a faster option than Self::distance
for some
cases, such as when comparing two distances.
Provided Methods§
Object Safety§
This trait is not object safe.