mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Added per-character color support to love.graphics.print/printf and Text objects. Resolves issue #865.
The aforementioned functions now optionally accept an array instead of a plain string. The array is in the format of: {{r, g, b [, a]}, "first colored text, ", {r, g, b [, a]}, "second colored text", ...}, where the color values specify the color to use in the next section of the text.
This commit is contained in:
@@ -851,7 +851,9 @@ int w_newText(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ t = instance()->newText(font); });
|
||||
else
|
||||
{
|
||||
std::string text = luax_checkstring(L, 2);
|
||||
std::vector<Font::ColoredString> text;
|
||||
luax_checkcoloredstring(L, 2, text);
|
||||
|
||||
luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
|
||||
}
|
||||
|
||||
@@ -1466,7 +1468,9 @@ int w_draw(lua_State *L)
|
||||
|
||||
int w_print(lua_State *L)
|
||||
{
|
||||
std::string str = luax_checkstring(L, 1);
|
||||
std::vector<Font::ColoredString> str;
|
||||
luax_checkcoloredstring(L, 1, str);
|
||||
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0);
|
||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
@@ -1485,7 +1489,9 @@ int w_print(lua_State *L)
|
||||
|
||||
int w_printf(lua_State *L)
|
||||
{
|
||||
std::string str = luax_checkstring(L, 1);
|
||||
std::vector<Font::ColoredString> str;
|
||||
luax_checkcoloredstring(L, 1, str);
|
||||
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float wrap = (float)luaL_checknumber(L, 4);
|
||||
|
||||
Reference in New Issue
Block a user