diff options
| author | bptato <nincsnevem662@gmail.com> | 2023-07-07 19:12:31 +0200 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2023-07-07 19:12:31 +0200 |
| commit | 45f58316b4da12e893856e47a4296ee09c49449e (patch) | |
| tree | 20ae54604051d9a7c2250b24cf6df9a802214a55 /src/types | |
| parent | da3c7385d1e19ba97aee0b6220d26994eef985e8 (diff) | |
| download | chawan-45f58316b4da12e893856e47a4296ee09c49449e.tar.gz | |
Fix toHex weirdness
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/color.nim | 9 |
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 & ")" |