From 0fcf1245ec98e4493365d59d97813475f89afe90 Mon Sep 17 00:00:00 2001 From: Gianni Alessandroni <45824238+NotManyIdeasDev@users.noreply.github.com> Date: Sun, 16 May 2021 11:44:40 +0200 Subject: [PATCH] Added DrawFPSEx() function with custom FPS colors and fontsize. This function allows the user to choose the colors to indicate good, medium or bad FPS, and also allows to change the font size. --- src/text.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/text.c b/src/text.c index 3e821fe80..e2e9e1ea5 100644 --- a/src/text.c +++ b/src/text.c @@ -826,6 +826,19 @@ void DrawFPS(int posX, int posY) DrawText(TextFormat("%2i FPS", GetFPS()), posX, posY, 20, color); } +// Draw current FPS with custom font size and custom color +// NOTE: Uses default font +void DrawFPSEx(int posX, int posY, int fontSize, Color highColor, Color midColor, Color lowColor) +{ + Color color = highColor; // good FPS + + int fps = GetFPS(); + if (fps < 30 && fps >= 15) color = midColor; // warning FPS + else if (fps < 15) color = lowColor; // bad FPS + + DrawText(TextFormat("%2i FPS", GetFPS()), posX, posY, fontSize, color); +} + // Draw text (using default font) // NOTE: fontSize work like in any drawing program but if fontSize is lower than font-base-size, then font-base-size is used // NOTE: chars spacing is proportional to fontSize