aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-25 21:38:47 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-25 21:38:56 +0200
commitc6fdc79ad5db4fe7305e909c389510d10ec5d4a9 (patch)
treea8f4d3d9d9041ac7e21a9f15f19b049522b2040b /src
parent61311815583046b1d97dba9fa911314e04036f79 (diff)
downloadchawan-c6fdc79ad5db4fe7305e909c389510d10ec5d4a9.tar.gz
color: fix a parseLegacyColor bug
Diffstat (limited to 'src')
-rw-r--r--src/types/color.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/types/color.nim b/src/types/color.nim
index 20de1fcc..13564f1d 100644
--- a/src/types/color.nim
+++ b/src/types/color.nim
@@ -493,11 +493,12 @@ func parseLegacyColor0*(s: string): RGBColor =
assert s != ""
if (let x = namedRGBColor(s); x.isSome):
return x.get
- if s.find(AllChars - AsciiHexDigit) == -1:
- let c = (hexValue(s[0]) * 17 shl 16) or
- (hexValue(s[1]) * 17 shl 8) or
- (hexValue(s[2]) * 17)
- return RGBColor(c)
+ if s.len == 4 and s[0] == '#':
+ let r = hexValue(s[1])
+ let g = hexValue(s[2])
+ let b = hexValue(s[3])
+ if r != -1 and g != -1 and b != -1:
+ return rgb(uint8(r * 17), uint8(g * 17), uint8(b * 17))
# o_0
var s2 = if s[0] == '#':
s.substr(1)