From bc53c82bcf923d11725e3de8565eb4c7e435cd2b Mon Sep 17 00:00:00 2001 From: Gael-de-Sailly Date: Fri, 27 Feb 2015 20:51:55 +0100 Subject: Add minetest.rgba function that returns ColorString from RGBA or RGB values --- builtin/common/misc_helpers.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index f9b572d9f..776be29d8 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -511,6 +511,12 @@ function core.explode_scrollbar_event(evt) return retval end +-------------------------------------------------------------------------------- +function core.rgba(r, g, b, a) + return a and string.format("#%02X%02X%02X%02X", r, g, b, a) or + string.format("#%02X%02X%02X", r, g, b) +end + -------------------------------------------------------------------------------- function core.pos_to_string(pos, decimal_places) local x = pos.x -- cgit v1.2.3