From 2bbf13cc3daf5cb4982d121a1c7f55d7679ca566 Mon Sep 17 00:00:00 2001 From: Verneuil Julien Date: Tue, 28 Apr 2015 01:31:25 +0200 Subject: [PATCH] added file/function to format rgba color to css style color --- web/CXM_style_tools.anubis | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+), 0 deletions(-) create mode 100644 web/CXM_style_tools.anubis diff --git a/web/CXM_style_tools.anubis b/web/CXM_style_tools.anubis new file mode 100644 index 0000000..776903b --- /dev/null +++ b/web/CXM_style_tools.anubis @@ -0,0 +1,18 @@ +public define String + format_rgba_to_style_color + ( + RGBA color + ) = + if color is + { + rgba(r, g, b, a) then + with alpha_str = + if to_Float(word32(word16(a, 0), word16(0, 0))) / 255.0 is + { + failure then "1", + success(v) then + float_to_string(v, 8) + }, + + "rgba(" + to_decimal(r) + "," + to_decimal(g) + "," + to_decimal(b) + "," + alpha_str + ");" + }. -- libgit2 0.21.4