Fix assert for 256 colors

This commit is contained in:
Alexandre Bury 2018-01-27 17:26:03 -08:00
parent 4de8bd7363
commit 6f072ac894

View File

@ -98,14 +98,17 @@ impl Color {
Color::Rgb(value, value, value) Color::Rgb(value, value, value)
} else { } else {
let n = n - 16; let n = n - 16;
// We support 6*6*6 = 216 colors here
assert!(n < 216);
let r = n / 36; let r = n / 36;
let g = (n % 36) / 6; let g = (n % 36) / 6;
let b = n % 6; let b = n % 6;
assert!(r < 5); // Each color is in the range [0, 5] (6 possible values)
assert!(g < 5); assert!(r < 6);
assert!(b < 5); assert!(g < 6);
assert!(b < 6);
Color::RgbLowRes(r, g, b) Color::RgbLowRes(r, g, b)
} }