Skip to content

Commit

Permalink
Add min/max component function for Xyz
Browse files Browse the repository at this point in the history
  • Loading branch information
okaneco committed Mar 20, 2020
1 parent 9040cdd commit 5b11613
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions palette/src/xyz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,39 @@ where
pub fn from_components((x, y, z): (T, T, T)) -> Self {
Self::with_wp(x, y, z)
}

/// Return the `x` value minimum.
pub fn min_x() -> T {
T::zero()
}

/// Return the `x` value maximum.
pub fn max_x() -> T {
let xyz_ref: Xyz<Wp, _> = Wp::get_xyz();
xyz_ref.x
}

/// Return the `y` value minimum.
pub fn min_y() -> T {
T::zero()
}

/// Return the `y` value maximum.
pub fn max_y() -> T {
let xyz_ref: Xyz<Wp, _> = Wp::get_xyz();
xyz_ref.y
}

/// Return the `z` value minimum.
pub fn min_z() -> T {
T::zero()
}

/// Return the `z` value maximum.
pub fn max_z() -> T {
let xyz_ref: Xyz<Wp, _> = Wp::get_xyz();
xyz_ref.z
}
}

///<span id="Xyza"></span>[`Xyza`](type.Xyza.html) implementations.
Expand Down Expand Up @@ -668,6 +701,16 @@ mod test {
raw_pixel_conversion_tests!(Xyz<D65>: x, y, z);
raw_pixel_conversion_fail_tests!(Xyz<D65>: x, y, z);

#[test]
fn check_min_max_components() {
assert_relative_eq!(Xyz::<D65>::min_x(), 0.0);
assert_relative_eq!(Xyz::<D65>::min_y(), 0.0);
assert_relative_eq!(Xyz::<D65>::min_z(), 0.0);
assert_relative_eq!(Xyz::<D65, f64>::max_x(), X_N);
assert_relative_eq!(Xyz::<D65, f64>::max_y(), Y_N);
assert_relative_eq!(Xyz::<D65, f64>::max_z(), Z_N);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down

0 comments on commit 5b11613

Please sign in to comment.