SFML community forums
Help => Graphics => Topic started by: julen26 on January 13, 2012, 12:48:27 am
-
Is any way for drawing a gradient rectangle of 2 colors using ConvexShape, like I used to do in SFML2(old api)?
Something like this, working against points with colors:
sf::Shape m_back;
m_back.AddPoint(0, 0, sf::Color(50, 250, 200));
m_back.AddPoint(800, 0, sf::Color(50, 250, 200));
m_back.AddPoint(800, 600, sf::Color(25, 80, 40));
m_back.AddPoint(0, 600, sf::Color(25, 80, 40));
Thanks.
-
The sf::Shape classe(s) don't allow to set points color individually anymore, but you can do what you want very easily with vertices:
sf::Vertex rectangle[] =
{
sf::Vertex(point1, color1),
sf::Vertex(point2, color2),
sf::Vertex(point3, color3),
sf::Vertex(point4, color4)
};
window.Draw(rectangle, 4, sf::Quads);
-
Okay I understand.
Thanks Laurent.