diff options
author | bptato <nincsnevem662@gmail.com> | 2022-12-10 19:05:38 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-12-10 19:05:38 +0100 |
commit | 1e858c874804444bc4b95b6e89eb96a0deb8473c (patch) | |
tree | 3151b498e19c6d6eed3d90827483eb270314f3da /src/types | |
parent | d963385cd9fd77f0a950c5b92be7774bbf76d661 (diff) | |
download | chawan-1e858c874804444bc4b95b6e89eb96a0deb8473c.tar.gz |
Add support for the encoding standard, fix parseLegacyColor
Also, fix a bug in the
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/color.nim | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/types/color.nim b/src/types/color.nim index 64568964..3e29c15f 100644 --- a/src/types/color.nim +++ b/src/types/color.nim @@ -272,9 +272,14 @@ func parseLegacyColor*(s: string): Option[RGBColor] = let c1 = s2[0..<min(l,2)] let c2 = s2[l..<min(l*2,l+2)] let c3 = s2[l*2..<min(l*3,l*2+2)] - let c = (hexValue(c1[0]) shl 20) or (hexValue(c1[1]) shl 16) or - (hexValue(c2[0]) shl 12) or (hexValue(c2[1]) shl 8) or - (hexValue(c3[0]) shl 4) or hexValue(c3[1]) + let c = if l == 1: + (hexValue(c1[0]) shl 20) or (hexValue(c1[0]) shl 16) or + (hexValue(c2[0]) shl 12) or (hexValue(c2[0]) shl 8) or + (hexValue(c3[0]) shl 4) or hexValue(c3[0]) + else: + (hexValue(c1[0]) shl 20) or (hexValue(c1[1]) shl 16) or + (hexValue(c2[0]) shl 12) or (hexValue(c2[1]) shl 8) or + (hexValue(c3[0]) shl 4) or hexValue(c3[1]) return some(RGBColor(c)) func r*(c: RGBAColor): int = |