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
+3 -3
View File
@@ -183,7 +183,7 @@ public:
Mesh *newMesh(const std::vector<Mesh::AttribFormat> &vertexformat, int vertexcount, Mesh::DrawMode drawmode, Mesh::Usage usage);
Mesh *newMesh(const std::vector<Mesh::AttribFormat> &vertexformat, const void *data, size_t datasize, Mesh::DrawMode drawmode, Mesh::Usage usage);
Text *newText(Font *font, const std::string &text = "");
Text *newText(Font *font, const std::vector<Font::ColoredString> &text = {});
bool isGammaCorrect() const;
@@ -328,7 +328,7 @@ public:
* @param kx Shear along the x-axis.
* @param ky Shear along the y-axis.
**/
void print(const std::string &str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void print(const std::vector<Font::ColoredString> &str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
/**
* Draw formatted text on screen at the specified coordinates.
@@ -346,7 +346,7 @@ public:
* @param kx Shear along the x-axis.
* @param ky Shear along the y-axis.
**/
void printf(const std::string &str, float x, float y, float wrap, Font::AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void printf(const std::vector<Font::ColoredString> &str, float x, float y, float wrap, Font::AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
/**
* Draws a point at (x,y).