summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2017-08-06 10:44:50 +0200
committerraysan5 <[email protected]>2017-08-06 10:44:50 +0200
commit88839b093c47a478979eaf9a26a7341ff37d8b63 (patch)
treed6b35c44f6ce32b238674d87f04f013cc4ddd99f /src
parent0169b72bdca6890426f1e7f1824e7225afcb18ee (diff)
downloadraylib-88839b093c47a478979eaf9a26a7341ff37d8b63.tar.gz
raylib-88839b093c47a478979eaf9a26a7341ff37d8b63.zip
Added function DrawRectangleT()
Usefult to draw rectangles using default font texture
Diffstat (limited to 'src')
-rw-r--r--src/raylib.h1
-rw-r--r--src/text.c19
2 files changed, 15 insertions, 5 deletions
diff --git a/src/raylib.h b/src/raylib.h
index bad711d9..85499eb1 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -952,6 +952,7 @@ RLAPI void DrawFPS(int posX, int posY);
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
float fontSize, int spacing, Color tint);
+RLAPI void DrawRectangleT(int posX, int posY, int width, int height, Color color); // Draw rectangle using text character
// Text misc. functions
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
diff --git a/src/text.c b/src/text.c
index 7ef01c11..fe00ce86 100644
--- a/src/text.c
+++ b/src/text.c
@@ -139,10 +139,10 @@ extern void LoadDefaultFont(void)
0x04000404, 0x4100203c, 0x00000000, 0x00000800, 0xf7df7df0, 0x514bef85, 0xbefbefbe, 0x04513bef, 0x14414500, 0x494a2885, 0xa28a28aa, 0x04510820,
0xf44145f0, 0x474a289d, 0xa28a28aa, 0x04510be0, 0x14414510, 0x494a2884, 0xa28a28aa, 0x02910a00, 0xf7df7df0, 0xd14a2f85, 0xbefbe8aa, 0x011f7be0,
0x00000000, 0x00400804, 0x20080000, 0x00000000, 0x00000000, 0x00600f84, 0x20080000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0xac000000, 0x00000f01, 0x00000000, 0x00000000, 0x24000000, 0x00000901, 0x00000000, 0x06000000, 0x24000000, 0x00000901, 0x00000000, 0x09108000,
- 0x24fa28a2, 0x00000901, 0x00000000, 0x013e0000, 0x2242252a, 0x00000952, 0x00000000, 0x038a8000, 0x2422222a, 0x00000929, 0x00000000, 0x010a8000,
- 0x2412252a, 0x00000901, 0x00000000, 0x010a8000, 0x24fbe8be, 0x00000901, 0x00000000, 0x0ebe8000, 0xac020000, 0x00000f01, 0x00000000, 0x00048000,
- 0x0003e000, 0x00000000, 0x00000000, 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x8443b80e, 0x00203a03,
+ 0xac000000, 0x00000f01, 0x00000000, 0x00000000, 0x24000000, 0x00000f01, 0x00000000, 0x06000000, 0x24000000, 0x00000f01, 0x00000000, 0x09108000,
+ 0x24fa28a2, 0x00000f01, 0x00000000, 0x013e0000, 0x2242252a, 0x00000f52, 0x00000000, 0x038a8000, 0x2422222a, 0x00000f29, 0x00000000, 0x010a8000,
+ 0x2412252a, 0x00000f01, 0x00000000, 0x010a8000, 0x24fbe8be, 0x00000f01, 0x00000000, 0x0ebe8000, 0xac020000, 0x00000f01, 0x00000000, 0x00048000,
+ 0x0003e000, 0x00000f00, 0x00000000, 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x8443b80e, 0x00203a03,
0x02bea080, 0xf0000020, 0xc452208a, 0x04202b02, 0xf8029122, 0x07f0003b, 0xe44b388e, 0x02203a02, 0x081e8a1c, 0x0411e92a, 0xf4420be0, 0x01248202,
0xe8140414, 0x05d104ba, 0xe7c3b880, 0x00893a0a, 0x283c0e1c, 0x04500902, 0xc4400080, 0x00448002, 0xe8208422, 0x04500002, 0x80400000, 0x05200002,
0x083e8e00, 0x04100002, 0x804003e0, 0x07000042, 0xf8008400, 0x07f00003, 0x80400000, 0x04000022, 0x00000000, 0x00000000, 0x80400000, 0x04000002,
@@ -255,7 +255,7 @@ extern void LoadDefaultFont(void)
}
defaultFont.baseSize = defaultFont.chars[0].rec.height;
-
+
TraceLog(LOG_INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
}
@@ -457,6 +457,14 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
}
}
+// Draw rectangle using text character (char: 127)
+// NOTE: Useful to avoid changing to default white texture
+void DrawRectangleT(int posX, int posY, int width, int height, Color color)
+{
+ DrawTexturePro(GetDefaultFont().texture, GetDefaultFont().chars[95].rec,
+ (Rectangle){ posX, posY, width, height }, (Vector2){ 0, 0 }, 0.0f, color);
+}
+
// Formatting of text with variables to 'embed'
const char *FormatText(const char *text, ...)
{
@@ -632,6 +640,7 @@ static SpriteFont LoadImageFont(Image image, Color key, int firstChar)
{
if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break;
}
+
if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break;
}