about summary refs log tree commit diff stats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-11-26 14:33:41 +0100
committerbptato <nincsnevem662@gmail.com>2023-11-26 14:33:41 +0100
commita386b78fdc61b791b6df649326078383098bef5a (patch)
tree72cf72bc78e02dd645afaa3ddaa5747d558df406 /src/types
parent88f3e0ab699ec6f951183c3f9bfbd42f99337b58 (diff)
downloadchawan-a386b78fdc61b791b6df649326078383098bef5a.tar.gz
color: fix rgbToEightBit parentheses
This was causing incorrect approximation to grayscale values for
colors with a red component in 8 .. 248.
Diffstat (limited to 'src/types')
-rw-r--r--src/types/color.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/types/color.nim b/src/types/color.nim
index 155a22ad..5abe1a9e 100644
--- a/src/types/color.nim
+++ b/src/types/color.nim
@@ -409,7 +409,7 @@ func rgbToEightBit*(rgb: RGBColor): EightBitColor =
       return EightBitColor(16)
     if r > 248:
       return EightBitColor(231)
-    return EightBitColor(cast[uint8](((r - 8 * 24) div 247) + 232))
+    return EightBitColor(cast[uint8](((r - 8) * 24 div 247) + 232))
   #16 + 36 * r + 6 * g + b
   return EightBitColor(cast[uint8](16 + 36 * (r * 5 div 255) +
     6 * (g * 5 div 255) + (b * 5 div 255)))