[SDL] Font color gradients

Mason Wheeler masonwheeler at yahoo.com
Sat Apr 5 15:02:59 PDT 2008


Interesting.  Is there a way to create an alpha-only surface?  (No color information, only an alpha channel.)  I could render the font onto that and then do a bit of creative blitting...

----- Original Message ----
From: David Olsen <jolynsbass at gmail.com>
To: A list for developers using the SDL library. (includes SDL-announce) <sdl at lists.libsdl.org>
Sent: Saturday, April 5, 2008 2:36:51 PM
Subject: Re: [SDL] Font color gradients

I would think that using the output from SDL_TTF(Blended - the one that 
gives you a per-pixel alpha image), you could blit the text onto a 
predefined surface which contains a color gradient, and you should get a 
resulting image of the sort you want. (Oh, first you must have SRCALPHA 
turned on in both surfaces, or it won't act as a mask. Look at the 
documentation of the SDL_SetAlpha function) I might have the surface order 
reversed... you might need to blit the colored gradient surface onto the 
rendered text surface. But a little experimentation along those lines should 
get you set up.
-Dave


----- Original Message ----- 
From: "Mason Wheeler" <masonwheeler at yahoo.com>
To: <sdl at lists.libsdl.org>
Sent: Saturday, April 05, 2008 7:12 AM
Subject: [SDL] Font color gradients


> I've been looking through SDL_TTF, and it looks like the only option 
> available is to render a font in a single, solid color.  How would I do 
> gradients and other custom colorations?  The ideal way would be to use the 
> glyph shapes as "cutouts" in an existing graphic from an SDL_Surface, 
> which would allow custom colors to be defined beforehand.  If this isn't 
> feasible, I'd like to be able to define multiple foreground colors and 
> create a gradient from them.
>
> How would I go about doing something like this?
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org 

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





More information about the SDL mailing list