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

Author Topic: sf::LineShape(sf::Vector2f(x1, y1), sf::Vector2f(x2, y2));  (Read 2921 times)

0 Members and 1 Guest are viewing this topic.

Hydra

  • Newbie
  • *
  • Posts: 37
    • View Profile
sf::LineShape(sf::Vector2f(x1, y1), sf::Vector2f(x2, y2));
« 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);

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::LineShape(sf::Vector2f(x1, y1), sf::Vector2f(x2, y2));
« Reply #1 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 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.
« Last Edit: August 30, 2015, 10:42:08 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: