diff options
author | bptato <nincsnevem662@gmail.com> | 2023-11-11 22:27:26 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-11-11 22:27:26 +0100 |
commit | a3bd24ae53ea4e1d1c77dfc5a1171a05b5d9ca18 (patch) | |
tree | d87352e5bb7d98e8f5ee3e5fd072e622b9ca714b /src/types | |
parent | cc02a6c30af164f087e07f546f4177d0b9cf3bcb (diff) | |
download | chawan-a3bd24ae53ea4e1d1c77dfc5a1171a05b5d9ca18.tar.gz |
color: fix 3/6-digit hex color parsing
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/color.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/types/color.nim b/src/types/color.nim index 48f9d9e7..155a22ad 100644 --- a/src/types/color.nim +++ b/src/types/color.nim @@ -428,7 +428,8 @@ func parseHexColor*(s: string): Option[RGBAColor] = if hexValue(c) == -1: return none(RGBAColor) case s.len of 6: - let c = (hexValue(s[0]) shl 20) or (hexValue(s[1]) shl 16) or + let c = 0xFF000000 or + (hexValue(s[0]) shl 20) or (hexValue(s[1]) shl 16) or (hexValue(s[2]) shl 12) or (hexValue(s[3]) shl 8) or (hexValue(s[4]) shl 4) or hexValue(s[5]) return some(RGBAColor(c)) @@ -439,7 +440,8 @@ func parseHexColor*(s: string): Option[RGBAColor] = (hexValue(s[4]) shl 4) or hexValue(s[5]) return some(RGBAColor(c)) of 3: - let c = (hexValue(s[0]) shl 20) or (hexValue(s[0]) shl 16) or + let c = 0xFF000000 or + (hexValue(s[0]) shl 20) or (hexValue(s[0]) shl 16) or (hexValue(s[1]) shl 12) or (hexValue(s[1]) shl 8) or (hexValue(s[2]) shl 4) or hexValue(s[2]) return some(RGBAColor(c)) |