diff --git a/src/jstrutils.nim b/src/jstrutils.nim index 63a9ae8..507e7a6 100644 --- a/src/jstrutils.nim +++ b/src/jstrutils.nim @@ -14,6 +14,7 @@ proc `&`*(a, b: cstring): cstring {.importcpp: "(# + #)", nodecl.} proc toCstr*(s: int): cstring {.importcpp: "((#)+'')", nodecl.} proc `&`*(s: int): cstring {.importcpp: "((#)+'')", nodecl.} proc `&`*(s: bool): cstring {.importcpp: "((#)+'')", nodecl.} +proc `&`*(s: float): cstring {.importcpp: "((#)+'')", nodecl.} proc `&`*(s: cstring): cstring {.importcpp: "(#)", nodecl.} diff --git a/src/vstyles.nim b/src/vstyles.nim index 649c322..161c207 100644 --- a/src/vstyles.nim +++ b/src/vstyles.nim @@ -255,3 +255,11 @@ proc applyStyle*(n: Node; s: VStyle) = n.style = Style() for x in s.mask: n.style.setStyle(toStyleAttrName[x], s.attrs[x]) + +import jstrutils + +proc rgb*(r, g, b: range[0..255]): cstring = + cstring"rgb(" & &r & cstring", " & &g & cstring", " & &b & cstring")" + +proc rgba*(r, g, b: range[0..255], alpha: float): cstring = + cstring"rgb(" & &r & cstring", " & &g & cstring", " & &b & cstring", " & &alpha & cstring")"