bevy_color/color_difference.rs
1//! Module for calculating distance between two colors in the same color space.
2
3/// Calculate the distance between this and another color as if they were coordinates
4/// in a Euclidean space. Alpha is not considered in the distance calculation.
5pub trait EuclideanDistance: Sized {
6 /// Distance from `self` to `other`.
7 fn distance(&self, other: &Self) -> f32 {
8 self.distance_squared(other).sqrt()
9 }
10
11 /// Distance squared from `self` to `other`.
12 fn distance_squared(&self, other: &Self) -> f32;
13}