Gamedev Framework (gf)  0.8.0
A C++14 framework for 2D games
Public Types | Public Member Functions | List of all members
gf::Polyline Class Reference

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 (ArrayRef< 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...
 
void addPoint (Vector2f point)
 Add a point to the polyline. More...
 
std::size_t getPointCount () const
 Get the number of points of the polyline. More...
 
Vector2f getPoint (std::size_t index) const
 Get the i-th point of the polyline. More...
 
const Vector2fbegin () const
 Get an iterator to the first point. More...
 
const Vector2fend () const
 Get an iterator past the last point. 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...
 
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...
 
void setType (Type type)
 Set 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...
 

Detailed Description

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).

Member Enumeration Documentation

◆ Type

The type of polyline.

Enumerator
Chain 

The polyline is open.

Loop 

The polyline is closed.

Constructor & Destructor Documentation

◆ Polyline() [1/3]

gf::Polyline::Polyline ( Type  type = Chain)
inline

Default constructor.

Parameters
typeThe type of polyline (default: chain)

◆ Polyline() [2/3]

gf::Polyline::Polyline ( ArrayRef< Vector2f points,
Type  type = Chain 
)
inline

Constructor from an array.

Parameters
pointsThe array of points
typeThe type of polyline (default: chain)

◆ Polyline() [3/3]

template<typename Iterator >
gf::Polyline::Polyline ( Iterator  first,
Iterator  last,
Type  type = Chain 
)
inline

Constructor from points.

Parameters
firstIterator to the first point
lastIterator after the last point
typeThe type of polyline (default: chain)

Member Function Documentation

◆ addPoint()

void gf::Polyline::addPoint ( Vector2f  point)

Add a point to the polyline.

Parameters
pointThe point to add to the polyline

◆ begin()

const Vector2f* gf::Polyline::begin ( ) const

Get an iterator to the first point.

Returns
A pointer to the first point
See also
end()

◆ end()

const Vector2f* gf::Polyline::end ( ) const

Get an iterator past the last point.

Returns
A pointer past the last point
See also
begin()

◆ getNextPoint()

Vector2f gf::Polyline::getNextPoint ( std::size_t  i) const

Get the point after the i-th point.

Parameters
iThe index of the current point
Returns
The point after the current point
See also
hasNextPoint()

◆ getPoint()

Vector2f gf::Polyline::getPoint ( std::size_t  index) const

Get the i-th point of the polyline.

Parameters
indexThe index of the point

◆ getPointCount()

std::size_t gf::Polyline::getPointCount ( ) const

Get the number of points of the polyline.

Returns
The number of points of the polyline

◆ getPrevPoint()

Vector2f gf::Polyline::getPrevPoint ( std::size_t  i) const

Get the point before the i-th point.

Parameters
iThe index of the current point
Returns
The point before the current point
See also
hasPrevPoint()

◆ hasNextPoint()

bool gf::Polyline::hasNextPoint ( std::size_t  i) const

Check if there is a point after the i-th point.

Parameters
iThe index of the current point
Returns
True if there is a point after the current point
See also
getNextPoint()

◆ hasPrevPoint()

bool gf::Polyline::hasPrevPoint ( std::size_t  i) const

Check if there is a point before the i-th point.

Parameters
iThe index of the current point
Returns
True if there is a point before the current point
See also
getPrevPoint()

◆ isChain()

bool gf::Polyline::isChain ( ) const
inline

Check is the polyline is a chain.

Returns
True if the polyline is a chain
See also
isLoop(), setType()

◆ isLoop()

bool gf::Polyline::isLoop ( ) const
inline

Check is the polyline is a loop.

Returns
True if the polyline is a loop
See also
isChain(), setType()

◆ setType()

void gf::Polyline::setType ( Type  type)
inline

Set the type of the polyline.

Parameters
typeThe new type of the polyline