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

Author Topic: sf::LineShape() and sf::EllipseShape()?  (Read 2146 times)

0 Members and 1 Guest are viewing this topic.

Shadowblitz16

  • Newbie
  • *
  • Posts: 13
    • View Profile
sf::LineShape() and sf::EllipseShape()?
« on: October 23, 2019, 01:33:43 am »
why isn't there a sf::LineShape() and sf::EllipseShape() in the sfml graphics library?
these are really basic shapes that should be added for ease of use.

I come from love2d where drawing a line is as simple as love.graphics.line(x1,y1,x2,y2) and a ellipse is as simple as love.graphics.ellipse(drawmode,x,y,xr,yr); and setting the width of a line shape is as easy as.. love.graphics.setlinewidth(width);

anyways missing these just doesn't sound simple or fast can they be added?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::LineShape() and sf::EllipseShape()?
« Reply #1 on: October 23, 2019, 02:30:13 am »
Quote
There's no shape class for lines. The reason is simple: If your line has a thickness, it is a rectangle. If it doesn't, it can be drawn with a line primitive.
- Shapes tutorial (Built-in shape types - under "Lines")

It also shows you how to draw them.

In that very Shapes tutorial, in the Custom Shape Types section, you can find a complete Ellipse shape type.



A number of other shapes can added on top of the sf::Shape base. It has restrictions though. Mainly, it's a triangle fan so cannot create all shapes, especially if it's concave or has a hole in it (like a ring).

Any other shape can be created using a vertex array.

Some things have already been created to save you from having to do it yourself. Selba Ward, for example, is a collection of drawables that can reduce the amount of stuff you have to create yourself. It includes lines and polylines (Spline), which would replace any need for you to make your own line class, especially since it does connected lines, thick lines, and Bezier curved lines 8)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Shadowblitz16

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::LineShape() and sf::EllipseShape()?
« Reply #2 on: October 23, 2019, 03:15:59 am »
this still is inconvenient for something that is suppose to be simple and fast.
also vertices don't have collision properties so they shouldn't be used as a tutorial for a line shape.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::LineShape() and sf::EllipseShape()?
« Reply #3 on: October 25, 2019, 12:27:50 am »
I am not sure what's so inconvenient about copying that Ellipse code into a file or copying the class you want from Selba Ward into your project. They're also pretty "simple" and "fast" ways to do it, since you keep wanting to focus on those words.

I am unsure about your point about collision. None of the built-in shapes have collision other than it being able to work out its own axis-aligned boundary box, you can do this for any set of vertices easily. This, of course, means that even using an sf::CircleShape would require to do your own collision code so it's best to write all your own collision code.


Eveything I've said aside, feel free to insist further and get a response from the SFML team that will tell you that it will not be added. There have been a number of discussions about this on this forum already and if you have a look, you will see the valid reasons why they won't.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*