SFML community forums

General => Feature requests => Topic started by: Hydra on August 30, 2015, 10:31:14 pm

Title: sf::LineShape(sf::Vector2f(x1, y1), sf::Vector2f(x2, y2));
Post by: Hydra on August 30, 2015, 10:31:14 pm
I've recently come from SDL to try out SFML and I've discovered there's no line shape class. I generally think it's pretty ridiculous to have rectangle, circle and that but not have the most basic line shape.

I've seen one reply to something on SFML that was the developer saying it can be created using VertexArrays but I don't understand the point then? It's basically like saying. Oh something a program doesn't work on your computer? Why don't you go build your own computer and program.

Yeah it can be created using VertexArrays but then so can a rectangle, a circle and so on. It seems like such a trivial feature that will save people the time of making there own custom class for something that should be implemented already. It seems just a bad argument to say to use VertexArrays when it can be implemented by the SFML developers. If your telling me to use VertexArrays then you might as well just tell me to make my own C++ graphics library.

For example in SDL you have SDL_RenderDrawLine(SDL_RENDERER, x1, y1, x2, y2). Which saves time from creating your own class every time you want to draw a line.

So basically I'm wondering if it's possible to simply add a LineShape class where you can say:

line.setPosition(sf::Vector2f(32, 32), sf::Vector2f(64, 64));
line.setFillColor(sf::Color::Red);
line.setOutlineColor(sf::Color::Green);
line.setOutlineThickness(5);
line.setThickness(10);
Title: Re: sf::LineShape(sf::Vector2f(x1, y1), sf::Vector2f(x2, y2));
Post by: Nexus on August 30, 2015, 10:39:06 pm
A line shape is a rectangle shape -- the only difference is that instead of thickness, start and end point, you specify position, size and rotation.

By the way, thor::Arrow (http://www.bromeon.ch/libraries/thor/v2.0/doc/classthor_1_1_arrow.html) is a ready-to use line class, with more features like arrow tips, and in the future possibly different line styles. There are also examples of line classes on the Wiki.