Skip to content

Commit

Permalink
fix: improve rgb2hsv precision
Browse files Browse the repository at this point in the history
  • Loading branch information
JiatLn committed May 6, 2023
1 parent 34bef2f commit 2f78337
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ color.saturation(); // 0.68
color.lightness(); // 0.8039

color.hsv_hue(); // 210.0
color.hsv_saturation(); // 0.28
color.hsv_value(); // 0.94
color.hsv_saturation(); // 0.2845
color.hsv_value(); // 0.9373

color.luma(); // 0.59
color.luminance(); // 0.79
Expand Down
2 changes: 1 addition & 1 deletion src/conversion/hsv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn rgb2hsv(color: (f64, f64, f64)) -> (f64, f64, f64) {
s = delta / max;
}

(round(h, 2), round(s, 2), round(v, 2))
(round(h, 4), round(s, 4), round(v, 4))
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions tests/color_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn test_color_channel() {
assert_eq!(color.lightness(), 0.8039);

assert_eq!(color.hsv_hue(), 210.0);
assert_eq!(color.hsv_saturation(), 0.28);
assert_eq!(color.hsv_value(), 0.94);
assert_eq!(color.hsv_saturation(), 0.2845);
assert_eq!(color.hsv_value(), 0.9373);

assert_eq!(color.luma(), 0.59);
assert_eq!(color.luminance(), 0.79);
Expand Down

0 comments on commit 2f78337

Please sign in to comment.