diff options
author | bptato <nincsnevem662@gmail.com> | 2023-11-26 14:33:41 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-11-26 14:33:41 +0100 |
commit | a386b78fdc61b791b6df649326078383098bef5a (patch) | |
tree | 72cf72bc78e02dd645afaa3ddaa5747d558df406 /src/types | |
parent | 88f3e0ab699ec6f951183c3f9bfbd42f99337b58 (diff) | |
download | chawan-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.nim | 2 |
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))) |