From 8dbc1da708a7e48433f335e4b76e02a30e47e638 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 21 Jun 2017 18:20:57 +0200 Subject: [PATCH] fixes #28 --- src/jstrutils.nim | 1 + src/vstyles.nim | 8 ++++++++ 2 files changed, 9 insertions(+) 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")"