TTF_SetTextColor(3)

πŸ’– TTF_SetTextColor(3) πŸ’–

okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the group chat, where we make text go from "meh, white" to "main character in every colour" πŸ’…βœ¨


πŸŽ€ NAME πŸŽ€

TTF_SetTextColor</p> β€” set the color of a text object. literally that. that's the whole job. and she does it beautifully. 🌈


πŸ“ HEADER FILE πŸ“

Defined in SDL3_ttf/SDL_ttf.h β€” go get your include, bestie, she's right there 🫢


✨ SYNOPSIS ✨

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_SetTextColor(TTF_Text *text, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

four little numbers and a dream, no cap 🌸


πŸ’… DESCRIPTION πŸ’…

so here's the tea: the default text color is white (255, 255, 255, 255). which is fine, she's a classic, she ate. but if you want your text to be giving something more? that's what this function is for, bestie. red, green, blue, and alpha, all in one go. 🎨


🌸 FUNCTION PARAMETERS 🌸

  • text β€” the TTF_Text to modify. your text object. the one you're about to glow up. πŸ’–
  • r β€” the red color value in the range of 0-255. πŸ”΄
  • g β€” the green color value in the range of 0-255. 🟒
  • b β€” the blue color value in the range of 0-255. πŸ”΅
  • a β€” the alpha value in the range of 0-255. πŸ‘» (that's the transparency vibe check, iykyk)

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns true on success or false on failure. and if she says false? not me crying. 😭 call SDL_GetError() for more information β€” she will tell you what went wrong, fr fr.


🧡 THREAD SAFETY 🧡

This function should be called on the thread that created the text. periodt. don't be out here calling her from some random thread, that's not the vibe 🚫


⭐ AVAILABILITY ⭐

This function is available since SDL_ttf 3.0.0. she's been iconic since day one, no notes πŸ’œ


πŸ”₯ SEE ALSO πŸ”₯

(yes, the bullets are real, yes they're just like that, we don't ask questions, we love her anyway πŸ¦‹)


and that's the whole page, bestie!! 🫢 this lil slice of SDL_ttf is brought to you by SDL_ttf 3.2.2, straight from the SDL_ttf crew β€” go set some colors, you absolute icon βœ¨πŸ’–πŸŽ€πŸŒˆπŸ’…

πŸ“¦ where this page comes from