Hi people,
I've got a "pseudo"-concave shape consisting of three triangles.
The question: Is it possible to fill it in a way, that it looks like the right shape (picture attached; right shape filled with paint.net).
Of course, I could draw and use sprites for everything, but they aren't as lightweight as "shapes" and I will need
several thousands of those shapes. Further they can be scaled without quality loss.
Is there any algorithm for the color filling that recognizes the right edges and so on?
Or is it even possible (without using external libraries)? Many thx in advance for any tips!
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(500,500), "Map", sf::Style::Close);
window.setFramerateLimit(40);
sf::ConvexShape convex;
convex.setPointCount(3);
convex.setFillColor(sf::Color(110,150,190,255));
convex.setPoint(0, sf::Vector2f(170, 350));
convex.setPoint(1, sf::Vector2f(35, 250));
convex.setPoint(2, sf::Vector2f(236, 214));
sf::ConvexShape convex2;
convex2.setPointCount(3);
convex2.setFillColor(sf::Color(110,150,190,255));
convex2.setPoint(0, sf::Vector2f(170, 350));
convex2.setPoint(1, sf::Vector2f(217, 253));
convex2.setPoint(2, sf::Vector2f(300, 370));
sf::ConvexShape convex3;
convex3.setPointCount(3);
convex3.setFillColor(sf::Color(110,150,190,255));
convex3.setPoint(0, sf::Vector2f(170, 350));
convex3.setPoint(1, sf::Vector2f(300, 370));
convex3.setPoint(2, sf::Vector2f(156, 417));
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
window.clear();
window.draw(convex);
window.draw(convex2);
window.draw(convex3);
window.display();
}
return 0;
}