Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Gradient  (Read 3513 times)

0 Members and 2 Guests are viewing this topic.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[Solved] Gradient
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[Solved] Gradient
« Reply #1 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.
Laurent Gomila - SFML developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[Solved] Gradient
« Reply #2 on: June 22, 2008, 01:38:03 pm »
That was easy, I almost thought you were lying ;) Thanks