bevy_color/
color_difference.rs

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