-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add sf::LineShape
#2063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sf::LineShape
#2063
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2063 +/- ##
==========================================
- Coverage 13.94% 13.90% -0.05%
==========================================
Files 189 189
Lines 15821 15817 -4
Branches 4179 4169 -10
==========================================
- Hits 2207 2199 -8
- Misses 13460 13464 +4
Partials 154 154
Continue to review full report at Codecov.
|
|
I personally don’t see much value in adding this, there are already great libraries built on top of SFML which offer this (or it’s relatively simple to roll your own) and although it seems simple on the surface, a line shape like this can actually get quite complex use cases. |
ace9ab6 to
895699f
Compare
Isn't that rather a reason for adding a line shape to SFML? In the past, it was often recommended that It's well possible that there may be further feature requests though, e.g. end style (rectangular, pointy, rounded, arrow), line style (constant, dotted, dashed), etc. Regarding implementation, I like the current one, as it is fairly simple. One possible change would be to cache the |
e7a1ac5 to
25a6919
Compare
Sorry I don't quite understand how? It would mean we have to implement or at least consider the more complex use-cases as well as dealing with further feature requests (as you say). It would also like make the implementation/API much less simple than it currently is
Yeah this use-case has been mentioned a few times in this discussion but I struggle to get on board with it. Debug lines are easily done with existing primitives, with this new class only offering the benefit of thickness, which is not something I've ever desired with my debug tools. Based on my experience using lines with thickness (for end products, not debugging) there are a couple of things I've needed in my own implementations that I would question for this one:
|
It's more than just
Currently line segments can use any two start and end points while the rotation remains zero. An alternative solution is to dynamically update the rotation to match the direction to the end point. Then we just store a length and thickness internally. This approach might be friendlier to applying textures.
This is why we also ought to consider |
82b6782 to
4a6f676
Compare
c53a94c to
3e84346
Compare
|
While I can understand most arguments against a The fact that just about every SFML extension library has added such a line shape in one way or another and we have a multiple implementations in the community wiki is a strong indication that this is something SFML should provide out of the box.
Additionally, it's an often requested feature, which is also a good measure to show what people want - interestingly enough, each of these requests, is immediately followed by a link to one of the implementations above.
With that, I believe it's quite undeniable that there is demand for such a functionality. Now for some of the arguments...
There are many potential more complex use cases for other shapes as well (dotted outlines, rounded rectangles, different colored for each side outline, etc.). Just because there's a potential for additional feature requests, doesn't mean that we have to follow through with these requests, nor that they will actually happen. It's good to discuss some of those points for the initial implementation and define what problem the sf::LineShape solves, but it's not a good argument against the feature overall. On the other hand, why are things like an arrow class or a rounded line or a spline not something SFML should have from the get go?
I believe this highly depends on the API we build for
This is certainly something we need to make a decision on. Should a line only have an outline on the "long" side or all around it? Or should it be configurable? Are there any additional arguments? My personal design goals for a
|
|
@eXpl0it3r Thanks a lot for the detailed research, this greatly summarizes the discussion!
I think the most straightforward approach would be if line didn't have an outline at all -- or, the line itself is the outline. This is how user software like Microsoft Word does it. There, shapes have the following properties:
For line-like shapes (lines, arrows, curves), the Fill property is simply disabled, because it's meaningless. So everything is determined through the outline. Back to SFML, this shows a LSP issue with
|
6b76cf7 to
79f64d3
Compare
2a04002 to
917284f
Compare
|
Fixed minor merge conflict. |
917284f to
3fec571
Compare
|
Rebasing to keep up with |
3fec571 to
4cdc46d
Compare
|
Fixed trivial merge conflict. |
4cdc46d to
03725e7
Compare
|
Rebased and reformatted because of #2159 |
03725e7 to
fb77949
Compare
|
Rebased and fixed compiler error. |
fb77949 to
5da8c5e
Compare
|
Rebased because it's been a while and because I needed to convert some |
|
Consider calling this |
|
@eXpl0it3r @Bromeon: would you be in favour of this PR if we rename it as What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this PR. While the outline issue is still there, it could be addressed in a later refactoring.
I don't think it's necessary to rename LineShape to LineSegmentShape. In 2D graphics, the term "line" is often used to refer to the concept as embodied by this PR. I encountered "line segment" more in mathematical contexts where lines are infinite, or when the graphics library needs to explicitly distinguish the two.
If you want to keep the term "line" for more fancy shapes like bezier, poly-lines etc, I'd probably rather use "curve" for those. "Line" seems very connected to "straight" to me 🙂
5da8c5e to
a8aa9f8
Compare
|
Rebased to catch up with |
a8aa9f8 to
536987b
Compare
|
Rebased to get new CI jobs. |
d73bbf3 to
0361288
Compare
0361288 to
0eb9929
Compare
|
Fixed small merge conflict with |
sf::LineShape models a line segment defined by two points. The first point specifies the position of the line segment and the segment is drawn to the second point.
0eb9929 to
9d224ee
Compare
|
I'm not interested in maintaining or discussing this anymore so I'm closing it (again). If motivation returns we can resurrect this but it's not worth keeping this open in the meantime. |
Description
sf::LineShapemodels a line segment defined by two points. The first point specifies the position of the line segment and the segment is drawn to the second point. The goal is to give users the simplest possible API for something they're already doing, drawing lines.Here is an example of me using
sf::LineShapeto replacesf::RectangleShapein a project of mine.Tasks