mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-02 22:30:34 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3eecf55c46 | ||
|
|
25ea1eb064 | ||
|
|
e9dbf10433 |
@@ -39,12 +39,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn hsl_roundtrip() {
|
||||
for c in [Rgba::rgb(10, 200, 30), Rgba::rgb(255, 0, 0), Rgba::rgb(128, 128, 128), Rgba::rgb(21, 96, 130)] {
|
||||
let (h, s, l) = c.to_hsl();
|
||||
let d = Rgba::from_hsl(h, s, l, 255);
|
||||
for color in [Rgba::rgb(10, 200, 30), Rgba::rgb(255, 0, 0), Rgba::rgb(128, 128, 128), Rgba::rgb(21, 96, 130)] {
|
||||
let (hue, saturation, lightness) = color.to_hsl();
|
||||
let converted = Rgba::from_hsl(hue, saturation, lightness, 255);
|
||||
assert!(
|
||||
(d.r as i32 - c.r as i32).abs() <= 1 && (d.g as i32 - c.g as i32).abs() <= 1 && (d.b as i32 - c.b as i32).abs() <= 1,
|
||||
"{c:?} {d:?}"
|
||||
(i32::from(converted.r) - i32::from(color.r)).abs() <= 1
|
||||
&& (i32::from(converted.g) - i32::from(color.g)).abs() <= 1
|
||||
&& (i32::from(converted.b) - i32::from(color.b)).abs() <= 1,
|
||||
"{color:?} {converted:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user