SFML community forums
Help => Graphics => Topic started by: Roose Bolton of the Dreadfort on November 30, 2012, 02:23:18 pm
-
is it possible to have a fall off from the center off a circleshape? Say I want to use it as an overlay on top of a laser projectile, to give it some glow?
-
A quick search returned :
http://en.sfml-dev.org/forums/index.php?topic=3473.0
Looking at his source, the guy basically draws each pixel separately. This, along with the absence of gradient class, makes me think SFML does not support gradient.
I think you're better off using a gradient bitmap, possibly re-colorizing it ; or perhaps some shader could do the trick.
-
It is not possible directly with one of the classes SFML provides (ie SFML does not provied gradient classes). That means you have to implement it yourself. Take a look at the wiki though. This class (https://github.com/SFML/SFML/wiki/Source%3A-Color-Gradient) might be helpful to you.
-
Custom shapes with gradients can easily be created with a vertex array: if you assign different colors to the vertices that compose a primitive (ie. a triangle or quad), these colors are linearly interpolated by the graphics card to fill the primitive, and you get a smooth gradient with no effort.
-
But this doesn't work with circular gradients... :(
Maybe your could approximate it with many star-shaped triangles... :-S
-
Everything is made of triangles, even circles.
-
I was actually comparing it with the "ColorGradient" class posted above, which builded the gradient pixel-by-pixel. At this level, approximation is... acceptable :p