From 6f072ac894662284351caa0269fb5a17ccdbd80d Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sat, 27 Jan 2018 17:26:03 -0800 Subject: [PATCH] Fix assert for 256 colors --- src/theme/color.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/theme/color.rs b/src/theme/color.rs index 6828f01..d4efbf5 100644 --- a/src/theme/color.rs +++ b/src/theme/color.rs @@ -98,14 +98,17 @@ impl Color { Color::Rgb(value, value, value) } else { let n = n - 16; + // We support 6*6*6 = 216 colors here + assert!(n < 216); let r = n / 36; let g = (n % 36) / 6; let b = n % 6; - assert!(r < 5); - assert!(g < 5); - assert!(b < 5); + // Each color is in the range [0, 5] (6 possible values) + assert!(r < 6); + assert!(g < 6); + assert!(b < 6); Color::RgbLowRes(r, g, b) }