TTF_SetTextColorFloat(3)
π TTF_SetTextColorFloat(3) π
okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the manual, where we make text go pretty colors β¨ This one lives in TTF_SetTextColorFloat(3) and it's literally the glow-up button for your text objects.
πΈ NAME πΈ
TTF_SetTextColorFloat</p> β Set the color of a text object. π¨
π HEADER FILE π
Defined in SDL3_ttf/SDL_ttf.h β yes bestie, that's the one you gotta #include. π«Ά
β¨ SYNOPSIS β¨
#include "SDL3_ttf/SDL_ttf.h"
bool TTF_SetTextColorFloat(TTF_Text *text, float r, float g, float b, float a);
π DESCRIPTION π
so like. the default text color? it's white. no cap. out of the box your text is sitting there in (1.0f, 1.0f, 1.0f, 1.0f) and honestly that's giving clean minimal aesthetic, but if you wanna switch the vibe, this is the function. π¦
π FUNCTION PARAMETERS π
textβ theTTF_Textto modify. that's your main character right there πrβ the red color value, normally in the range of0-1. π΄gβ the green color value, normally in the range of0-1. π’bβ the blue color value, normally in the range of0-1. π΅aβ the alpha value in the range of0-1. transparency moment π
β RETURN VALUE β
Returns true on success or false on failure β and if it fails, do NOT just sit there wondering bestie, call SDL_GetError() for more information. it will tell you what went wrong fr fr π
π§ THREAD SAFETY π§
This function should be called on the thread that created the text. like, it's loyal to its creator. don't be calling it from some random other thread, that's not the vibe. π
π AVAILABILITY π
This function is available since SDL_ttf 3.0.0. so if you're on something older... yeah. upgrade time. π₯
π¦ SEE ALSO π¦
β’(3),TTF_GetTextColorFloat(3)β go read the color back, bestie πβ’(3),TTF_SetTextColor(3)β the int-flavored sibling, iykyk
heads up bestie: the color values are normally in the range of0-1β that's what the manpage says, so that's what we're going with. don't come at me with255energy and expect me to vouch for it. π
and that's the whole page, periodt. πΈ this lil slice of wisdom is brought to you by SDL_ttf version SDL_ttf 3.2.2 β mwah, go make something iconic with it π β¨π«Ά
π¦ where this page comes from
- debian trixie: libsdl3-ttf-doc 3.2.2+ds-1 Β· Zlib
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- ubuntu questing: libsdl3-ttf-doc 3.2.2+ds-1
- ubuntu resolute: libsdl3-ttf-doc 3.2.2+ds-1build1 Β· Zlib
- ubuntu stonking: libsdl3-ttf-doc 3.2.2+ds-2 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms