diff options
author | Robin Gareus <robin@gareus.org> | 2017-02-18 16:11:18 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-02-18 16:11:18 +0100 |
commit | 4755c703f4b01cd7de01bda0c72686b93e34e120 (patch) | |
tree | b9730e049e820087b96c909a3f318eab8f8df102 /libs/ardour/lua_api.cc | |
parent | c40ccd5aaeb6e1c6ffd7f7685567444a26ded76f (diff) |
move color_to_rgba to LuaAPI for consistency
Diffstat (limited to 'libs/ardour/lua_api.cc')
-rw-r--r-- | libs/ardour/lua_api.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index 080ba12841..7da81b2965 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -503,6 +503,32 @@ ARDOUR::LuaAPI::hsla_to_rgba (lua_State *L) } int +ARDOUR::LuaAPI::color_to_rgba (lua_State *L) +{ + int top = lua_gettop (L); + if (top < 1) { + return luaL_argerror (L, 1, "invalid number of arguments, color_to_rgba (uint32_t)"); + } + uint32_t color = luabridge::Stack<uint32_t>::get (L, 1); + double r, g, b, a; + + /* libardour is no user of libcanvas, otherwise + * we could just call + * ArdourCanvas::color_to_rgba (color, r, g, b, a); + */ + r = ((color >> 24) & 0xff) / 255.0; + g = ((color >> 16) & 0xff) / 255.0; + b = ((color >> 8) & 0xff) / 255.0; + a = ((color >> 0) & 0xff) / 255.0; + + luabridge::Stack <double>::push (L, r); + luabridge::Stack <double>::push (L, g); + luabridge::Stack <double>::push (L, b); + luabridge::Stack <double>::push (L, a); + return 4; +} + +int ARDOUR::LuaAPI::build_filename (lua_State *L) { std::vector<std::string> elem; |