From ef21d3df75441ef8ef321440621b85677f7efd26 Mon Sep 17 00:00:00 2001 From: tusharsingh09 Date: Mon, 27 Dec 2021 21:33:05 +0530 Subject: [PATCH 1/4] 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 7f05445bde3c..cfd3bb781e4e 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 137ad1864259..9d2b28ed3cd9 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) { From c2a70b3f6870adfe9bdc1b747f6ba9f572103809 Mon Sep 17 00:00:00 2001 From: tusharsingh09 Date: Thu, 30 Dec 2021 15:08:54 +0530 Subject: [PATCH 2/4] Added SetWindowOpacity() --- src/raylib.h | 1 + src/rcore.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index cfd3bb781e4e..4c154d989cda 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -925,6 +925,7 @@ RLAPI void SetWindowPosition(int x, int y); // Set window RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) RLAPI void SetWindowSize(int width, int height); // Set window dimensions +RLAPI void SetWindowOpacity(float opacity); // Set window opacity, value opacity is between 0.0 and 1.0 (only PLATFORM_DESKTOP) RLAPI void *GetWindowHandle(void); // Get native window handle RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height diff --git a/src/rcore.c b/src/rcore.c index ec1601ca173c..ddda0d500335 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1534,6 +1534,16 @@ void SetWindowSize(int width, int height) #endif } +// Set window opacity, value opacity is between 0.0 and 1.0 +void SetWindowOpacity (float opacity) +{ +#if defined(PLATFORM_DESKTOP) + if (opacity >= 1.0) opacity = 1.0; + else if (opacity <= 0.0) opacity = 0.0; + glfwSetWindowOpacity(CORE.Window.handle, opacity); +#endif +} + // Get current screen width int GetScreenWidth(void) { From dad6a9c0a5a749aaa58d3bb96235822c6424fab2 Mon Sep 17 00:00:00 2001 From: tusharsingh09 Date: Thu, 30 Dec 2021 15:16:53 +0530 Subject: [PATCH 3/4] Edited Mis-spell --- src/raylib.h | 2 -- src/rtext.c | 18 ------------------ 2 files changed, 20 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 4c154d989cda..a95b07231c73 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1331,8 +1331,6 @@ 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 9d2b28ed3cd9..137ad1864259 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -931,24 +931,6 @@ 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) { From 604259c022d7d76d8d20c5cc09a9efcca27e01e2 Mon Sep 17 00:00:00 2001 From: tusharsingh09 Date: Thu, 30 Dec 2021 17:17:37 +0530 Subject: [PATCH 4/4] Fixed conventions --- src/rcore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index ddda0d500335..f0e5876e9d3f 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1535,11 +1535,11 @@ void SetWindowSize(int width, int height) } // Set window opacity, value opacity is between 0.0 and 1.0 -void SetWindowOpacity (float opacity) +void SetWindowOpacity(float opacity) { #if defined(PLATFORM_DESKTOP) - if (opacity >= 1.0) opacity = 1.0; - else if (opacity <= 0.0) opacity = 0.0; + if (opacity >= 1.0f) opacity = 1.0f; + else if (opacity <= 0.0f) opacity = 0.0f; glfwSetWindowOpacity(CORE.Window.handle, opacity); #endif }