SFML community forums

Help => Graphics => Topic started by: dabo on June 22, 2008, 01:09:50 pm

Title: [Solved] Gradient
Post by: dabo on June 22, 2008, 01:09:50 pm
How do you draw a sf::Shape with a color gradient? Let's say I want a rectangle with a red top and a blue bottom. Would be interesting to know the math behind the color calculations.
Title: [Solved] Gradient
Post by: Laurent on June 22, 2008, 01:12:15 pm
Each point has its own color, then the shape is filled using a simple interpolation between all points.

In this case, you just have to assign a blue color to the 2 top points, and a red color to the 2 bottom points.
Title: [Solved] Gradient
Post by: dabo on June 22, 2008, 01:38:03 pm
That was easy, I almost thought you were lying ;) Thanks