aboutsummaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-07 19:12:31 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-07 19:12:31 +0200
commit45f58316b4da12e893856e47a4296ee09c49449e (patch)
tree20ae54604051d9a7c2250b24cf6df9a802214a55 /src/types
parentda3c7385d1e19ba97aee0b6220d26994eef985e8 (diff)
downloadchawan-45f58316b4da12e893856e47a4296ee09c49449e.tar.gz
Fix toHex weirdness
Diffstat (limited to 'src/types')
-rw-r--r--src/types/color.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/types/color.nim b/src/types/color.nim
index d3526a43..e628b9ad 100644
--- a/src/types/color.nim
+++ b/src/types/color.nim
@@ -251,10 +251,11 @@ func a*(c: RGBAColorPremul): uint8 {.borrow.}
# https://html.spec.whatwg.org/#serialisation-of-a-color
func serialize*(color: RGBAColor): string =
if color.a == 255:
- let r = toHex(cast[uint8](color.r))
- let g = toHex(cast[uint8](color.g))
- let b = toHex(cast[uint8](color.b))
- return "#" & r & g & b
+ var res = "#"
+ res.pushHex(color.r)
+ res.pushHex(color.g)
+ res.pushHex(color.b)
+ return res
let a = float64(color.a) / 255
return "rgba(" & $color.r & ", " & $color.g & ", " & $color.b & ", " & $a &
")"