![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
A Catmull–Rom spline. More...
#include <gf/Curves.h>
Public Types | |
enum | Type { Uniform , Chordal , Centripetal } |
The type of the spline. More... | |
![]() | |
enum | Type { Simple , Outlined } |
The type of the curve. More... | |
Public Member Functions | |
SplineCurve (Type type=Centripetal, std::size_t pointCount=30) | |
Constructor. More... | |
void | setControlPoints (const Polyline &line) |
Set the control points of the spline. More... | |
std::size_t | getPointCount () const override |
Get the total number of points of the curve. More... | |
Vector2f | getPoint (std::size_t index) const override |
Get a point of the curve. More... | |
![]() | |
Curve () | |
Default constructor. More... | |
void | setType (Type type) |
Set the type of the curve. More... | |
Type | getType () const noexcept |
Return the type of the curve. More... | |
void | setColor (const Color4f &color) |
Set the fill color of the curve. More... | |
const Color4f & | getColor () const |
Get the fill color of the curve. More... | |
void | setWidth (float width) |
Set the width of the curve. More... | |
float | getWidth () const |
Get the width of the curve. More... | |
void | setOutlineColor (const Color4f &color) |
Set the outline color of the curve. More... | |
const Color4f & | getOutlineColor () const |
Get the outline color of the curve. More... | |
void | setOutlineThickness (float thickness) |
Set the thickness of the curve's outline. More... | |
float | getOutlineThickness () const |
Get the outline thickness of the curve. More... | |
virtual std::size_t | getPointCount () const =0 |
Get the total number of points of the curve. More... | |
virtual Vector2f | getPoint (std::size_t index) const =0 |
Get a point of the curve. More... | |
RectF | getLocalBounds () const |
Get the local bounding rectangle of the entity. More... | |
void | setAnchor (Anchor anchor) |
Set the anchor origin of the entity. More... | |
VertexBuffer | commitGeometry () const |
Create a buffer with the current geometry. More... | |
VertexBuffer | commitOutlineGeometry () const |
Create a buffer with the current outline geometry. More... | |
virtual void | draw (RenderTarget &target, const RenderStates &states) override |
Draw the object to a render target. More... | |
![]() | |
Transformable () | |
Default constructor. More... | |
void | setOrigin (Vector2f origin) |
Set the local origin of the object. More... | |
Vector2f | getOrigin () const |
Get the local origin of the object. More... | |
void | setPosition (Vector2f position) |
Set the position of the object. More... | |
Vector2f | getPosition () const |
Get the position of the object. More... | |
void | move (Vector2f offset) |
Move the object by a given offset. More... | |
void | setRotation (float angle) |
Set the orientation of the object. More... | |
float | getRotation () const |
Get the orientation of the object. More... | |
void | rotate (float angle) |
Rotate the object. More... | |
void | setScale (Vector2f factors) |
Set the scale factors of the object. More... | |
void | setScale (float factor) |
Set the scale factor of the object. More... | |
Vector2f | getScale () const |
Get the current scale of the object. More... | |
void | scale (Vector2f factors) |
Scale the object. More... | |
void | scale (float factor) |
Scale the object. More... | |
Matrix3f | getTransform () const |
Get the combined transform of the object. More... | |
Matrix3f | getInverseTransform () const |
Get the inverse of the combined transform of the object. More... | |
![]() | |
virtual | ~Drawable () |
Virtual desctructor. More... | |
virtual void | draw (RenderTarget &target, const RenderStates &states)=0 |
Draw the object to a render target. More... | |
Additional Inherited Members | |
![]() | |
void | updateGeometry () |
Recompute the internal geometry of the curve. More... | |
void | setClosed (bool closed=true) |
Set the curve closed. More... | |
![]() | |
void | setOriginFromAnchorAndBounds (Anchor anchor, const RectF &bounds) |
Set the origin from an anchor and bounds. More... | |
A Catmull–Rom spline.
The type of the spline.
It determines the how the knot sequence is computed. For two points \( P_0 \) and \( P_1 \) with a euclidean distance of \( D \), and corresponding knots \( t_0 \) and \( t_1 \), the general formula is given by \( t_1 = t_0 + D^{\alpha} \). The type determines the value of \( \alpha \).
Enumerator | |
---|---|
Uniform | A uniform spline ( \( \alpha = 0.0 \)) |
Chordal | A uniform spline ( \( \alpha = 1.0 \)) |
Centripetal | A uniform spline ( \( \alpha = 0.5 \)) |
gf::SplineCurve::SplineCurve | ( | Type | type = Centripetal , |
std::size_t | pointCount = 30 |
||
) |
Constructor.
type | The type of spline |
pointCount | The number of points between two control points |
|
overridevirtual |
Get a point of the curve.
The returned point is in local coordinates, that is, the curve's transforms (position, rotation, scale) are not taken into account.
The result is undefined if index
is out of the valid range.
index | Index of the point to get, in range \( [0, n-1] \) where \( n \) is the number of points of the curve. |
Implements gf::Curve.
|
overridevirtual |
Get the total number of points of the curve.
Implements gf::Curve.
void gf::SplineCurve::setControlPoints | ( | const Polyline & | line | ) |
Set the control points of the spline.
line | The polyline that contains the points |