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.
This commit is contained in:
Gianni Alessandroni 2021-05-16 11:44:40 +02:00
parent b90ac7bd31
commit 0fcf1245ec

View File

@ -826,6 +826,19 @@ void DrawFPS(int posX, int posY)
DrawText(TextFormat("%2i FPS", GetFPS()), posX, posY, 20, color); 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) // 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: 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 // NOTE: chars spacing is proportional to fontSize