![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
A polyline. More...
#include <gf/Polyline.h>

Public Types | |
| enum | Type { Chain , Loop } |
| The type of polyline. More... | |
Public Member Functions | |
| Polyline (Type type=Chain) | |
| Default constructor. More... | |
| Polyline (Span< const Vector2f > points, Type type=Chain) | |
| Constructor from an array. More... | |
| template<typename Iterator > | |
| Polyline (Iterator first, Iterator last, Type type=Chain) | |
| Constructor from points. More... | |
| bool | hasPrevPoint (std::size_t i) const |
| Check if there is a point before the i-th point. More... | |
| Vector2f | getPrevPoint (std::size_t i) const |
| Get the point before the i-th point. More... | |
| Vector2f | getPrevExtensionPoint () const |
| Get the previous extension point of the first point. More... | |
| bool | hasNextPoint (std::size_t i) const |
| Check if there is a point after the i-th point. More... | |
| Vector2f | getNextPoint (std::size_t i) const |
| Get the point after the i-th point. More... | |
| Vector2f | getNextExtensionPoint () const |
| Get the next extension point of the last point. More... | |
| Winding | getWinding () const |
| Compute the winding of a simple loop polyline. More... | |
| bool | contains (Vector2f point) const |
| Test if a point is inside the polyline. More... | |
| void | setType (Type type) |
| Set the type of the polyline. More... | |
| Type | getType () const |
| Get the type of the polyline. More... | |
| bool | isLoop () const |
| Check is the polyline is a loop. More... | |
| bool | isChain () const |
| Check is the polyline is a chain. More... | |
Public Member Functions inherited from gf::PointSequence | |
| PointSequence ()=default | |
| Default constructor. More... | |
| PointSequence (Span< const Vector2f > points) | |
| Constructor from an array. More... | |
| template<typename Iterator > | |
| PointSequence (Iterator first, Iterator last) | |
| Constructor from points. More... | |
| bool | isEmpty () const |
| Check if the sequence is empty. More... | |
| void | addPoint (Vector2f point) |
| Add a point to the sequence. More... | |
| std::size_t | getPointCount () const |
| Get the number of points of the sequence. More... | |
| Vector2f | getPoint (std::size_t index) const |
| Get the i-th point of the sequence. More... | |
| Vector2f | getCenter () const |
| Get the center of the sequence. More... | |
| const Vector2f * | begin () const |
| Get an iterator to the first point. More... | |
| Vector2f * | begin () |
| Get an iterator to the first point. More... | |
| const Vector2f * | end () const |
| Get an iterator past the last point. More... | |
| Vector2f * | end () |
| Get an iterator past the last point. More... | |
| Vector2f | getFirstPoint () const |
| Get the first point of the sequence. More... | |
| Vector2f | getLastPoint () const |
| Get the last point of the sequence. More... | |
| void | applyTransform (const Matrix3f &mat) |
| Apply a transformation to the sequence. More... | |
| void | simplify (float distance=Epsilon) |
| Simplify the sequence. More... | |
| void | reverse () |
| Reverse the points in the sequence. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from gf::PointSequence | |
| std::vector< Vector2f > & | getRawPoints () |
| Get the raw container of points. More... | |
| const std::vector< Vector2f > & | getRawPoints () const |
| Get the raw container of points. More... | |
A polyline.
A polyline is a set of consecutive segments. It is defined by the points ending the segments. A polyline can be open (chain) or closed (loop).
| enum gf::Polyline::Type |
Default constructor.
| type | The type of polyline (default: chain) |
Constructor from an array.
| points | The array of points |
| type | The type of polyline (default: chain) |
|
inline |
Constructor from points.
| first | Iterator to the first point |
| last | Iterator after the last point |
| type | The type of polyline (default: chain) |
| bool gf::Polyline::contains | ( | Vector2f | point | ) | const |
Test if a point is inside the polyline.
If the polyline is a chain, it returns false.
| point | The point to test |
| Vector2f gf::Polyline::getNextExtensionPoint | ( | ) | const |
Get the next extension point of the last point.
When the line is a chain, the line can be extended with an extension point that is the symmetric of point at index \( (n-2) \) relative to the point at index \( (n-1) \). It may be useful for the computation of splines.
| Vector2f gf::Polyline::getNextPoint | ( | std::size_t | i | ) | const |
Get the point after the i-th point.
| i | The index of the current point |
| Vector2f gf::Polyline::getPrevExtensionPoint | ( | ) | const |
Get the previous extension point of the first point.
When the line is a chain, the line can be extended with an extension point that is the symmetric of point at index 1 relative to the point at index 0. It may be useful for the computation of splines.
| Vector2f gf::Polyline::getPrevPoint | ( | std::size_t | i | ) | const |
Get the point before the i-th point.
| i | The index of the current point |
|
inline |
Get the type of the polyline.
| Winding gf::Polyline::getWinding | ( | ) | const |
Compute the winding of a simple loop polyline.
Complexity: \( O(n) \)
| bool gf::Polyline::hasNextPoint | ( | std::size_t | i | ) | const |
Check if there is a point after the i-th point.
| i | The index of the current point |
| bool gf::Polyline::hasPrevPoint | ( | std::size_t | i | ) | const |
Check if there is a point before the i-th point.
| i | The index of the current point |
|
inline |
|
inline |
|
inline |
Set the type of the polyline.
| type | The new type of the polyline |