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 β€” the TTF_Text to modify. that's your main character right there πŸ‘‘
  • r β€” the red color value, normally in the range of 0-1. πŸ”΄
  • g β€” the green color value, normally in the range of 0-1. 🟒
  • b β€” the blue color value, normally in the range of 0-1. πŸ”΅
  • a β€” the alpha value in the range of 0-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 πŸ¦‹


heads up bestie: the color values are normally in the range of 0-1 β€” that's what the manpage says, so that's what we're going with. don't come at me with 255 energy 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