From ef21d3df75441ef8ef321440621b85677f7efd26 Mon Sep 17 00:00:00 2001 From: tusharsingh09 Date: Mon, 27 Dec 2021 21:33:05 +0530 Subject: [PATCH] Added drawing text with shadow --- src/raylib.h | 2 ++ src/rtext.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index 7f05445bd..cfd3bb781 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1330,6 +1330,8 @@ RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color co RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation) RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint) +RLAPI void DrawTextShadowed (const char* text, Vector2 position, Vector2 offset, float fontSize, float spacing, Color tint, Color shadowTint); // Draw text with a shadow +RLAPI void DrawTextShadowedEx (Font font, const char* text, Vector2 position, Vector2 offset, float fontSize, float spacing, Color tint, Color shadowTint); // Draw text with a shadow using Font parameter // Text font info functions RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font diff --git a/src/rtext.c b/src/rtext.c index 137ad1864..9d2b28ed3 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -931,6 +931,24 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz DrawTexturePro(font.texture, srcRec, dstRec, (Vector2){ 0, 0 }, 0.0f, tint); } +// Draw text with a shadow +void DrawTextShadowed (const char* text, Vector2 position, Vector2 offset, float fontSize, float spacing, Color tint, Color shadowTint) +{ + // Draw the shadow + DrawText (text, position.x + offset.x, position.y + offset.y, fontSize, shadowTint); + // Draw the actual text + DrawText (text, position.x, position.y, fontSize, tint); +} + +// Draw text with a shadow using Font parameter +void DrawTextShadowedEx (Font font, const char* text, Vector2 position, Vector2 offset, float fontSize, float spacing, Color tint, Color shadowTint) +{ + // Draw the shadow + DrawTextEx (font, text, (Vector2){position.x + offset.x, position.y + offset.y}, fontSize, spacing, shadowTint); + // Draw the actual text + DrawTextEx (font, text, position, fontSize, spacing, tint); +} + // Measure string width for default font int MeasureText(const char *text, int fontSize) {