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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.