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:
Alex Szpakowski
2015-11-01 23:17:46 -04:00
parent 799e303673
commit 389b91cf6f
9 changed files with 399 additions and 195 deletions
+7 -7
View File
@@ -38,15 +38,15 @@ class Text : public Drawable
{
public:
Text(Font *font, const std::string &text = "");
Text(Font *font, const std::vector<Font::ColoredString> &text = {});
virtual ~Text();
void set(const std::string &text);
void set(const std::string &text, float wrap, Font::AlignMode align);
void set(const std::vector<Font::ColoredString> &text);
void set(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align);
void set();
void add(const std::string &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void addf(const std::string &text, float wrap, Font::AlignMode align, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void add(const std::vector<Font::ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void clear();
// Implements Drawable.
@@ -69,7 +69,7 @@ private:
struct TextData
{
std::string text;
Font::ColoredCodepoints codepoints;
float wrap;
Font::AlignMode align;
bool use_matrix;
@@ -84,7 +84,7 @@ private:
StrongRef<Font> font;
GLBuffer *vbo;
std::vector<Font::DrawCommand> draw_commands;
Font::DrawCommands draw_commands;
std::vector<TextData> text_data;
Font::TextInfo text_info;