Convert to signed types before subtraction

main
Mitch Souders 2021-08-24 10:48:43 -07:00
parent e89c51cb84
commit 965989638a
1 changed files with 3 additions and 3 deletions

View File

@ -114,9 +114,9 @@ impl From<embedded_graphics_core::pixelcolor::Rgb888> for OctColor {
.iter()
.map(|c| (c, c.rgb()))
.map(|(c, (r, g, b))| {
let dist = ((r - p.r()) as u32).pow(2)
+ ((g - p.g()) as u32).pow(2)
+ ((b - p.b()) as u32).pow(2);
let dist = (i32::from(r) - i32::from(p.r())).pow(2)
+ (i32::from(g) - i32::from(p.g())).pow(2)
+ (i32::from(b) - i32::from(p.b())).pow(2);
(c, dist)
})
.min_by_key(|(_c, dist)| *dist)