Gamedev Framework (gf)  0.4.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::CompoundCurve Class Reference

A compound curve. More...

#include <gf/Curves.h>

Inheritance diagram for gf::CompoundCurve:
Inheritance graph
[legend]

Public Member Functions

 CompoundCurve (Vector2f origin=Vector2f(0, 0))
 Constructor. More...
 
CompoundCurvesetOrigin (Vector2f origin)
 Set the first point of the curve. More...
 
CompoundCurvelineTo (Vector2f p1)
 Create a line from the last point to a new point. More...
 
CompoundCurvequadraticCurveTo (Vector2f p1, Vector2f p2, std::size_t pointCount=20)
 Create a quadratic Bézier curve from the last point to a new point. More...
 
CompoundCurvecubicCurveTo (Vector2f p1, Vector2f p2, Vector2f p3, std::size_t pointCount=30)
 Create a cubic Bézier curve from the last point to a new point. More...
 
void close ()
 Close the curve. More...
 
CompoundCurveclear (Vector2f origin=Vector2f(0, 0))
 Reset the curve to a new origin. More...
 
virtual std::size_t getPointCount () const override
 Get the total number of points of the curve. More...
 
virtual Vector2f getPoint (std::size_t index) const override
 Get a point of the curve. More...
 
- Public Member Functions inherited from gf::Curve
 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 Color4fgetColor () 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 Color4fgetOutlineColor () 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...
 
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, RenderStates states)
 Draw the object to a render target. More...
 
- Public Member Functions inherited from gf::Transformable
 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...
 
- Public Member Functions inherited from gf::Drawable
virtual ~Drawable ()
 Virtual desctructor. More...
 

Additional Inherited Members

- Public Types inherited from gf::Curve
enum  Type {
  Simple,
  Outlined
}
 The type of the curve. More...
 
- Protected Member Functions inherited from gf::Curve
void updateGeometry ()
 Recompute the internal geometry of the curve. More...
 
void setClosed (bool closed=true)
 Set the curve closed. More...
 
- Protected Member Functions inherited from gf::Transformable
void setOriginFromAnchorAndBounds (Anchor anchor, const RectF &bounds)
 Set the origin from an anchor and bounds. More...
 

Detailed Description

A compound curve.

A compound curve is a curve composed of several continuous curves. It is sometimes called a path in vector graphics software.

Constructor & Destructor Documentation

gf::CompoundCurve::CompoundCurve ( Vector2f  origin = Vector2f(0, 0))

Constructor.

Parameters
originThe first point of the curve

Member Function Documentation

CompoundCurve& gf::CompoundCurve::clear ( Vector2f  origin = Vector2f(0, 0))

Reset the curve to a new origin.

The curve is open again.

Parameters
originThe first point of the curve
void gf::CompoundCurve::close ( )

Close the curve.

This create a line between the last point and the first point of the curve.

CompoundCurve& gf::CompoundCurve::cubicCurveTo ( Vector2f  p1,
Vector2f  p2,
Vector2f  p3,
std::size_t  pointCount = 30 
)

Create a cubic Bézier curve from the last point to a new point.

Parameters
p1The first control point
p2The second control point
p3The new end point
pointCountThe number of points composing the curve
virtual Vector2f gf::CompoundCurve::getPoint ( std::size_t  index) const
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.

Parameters
indexIndex of the point to get, in range \( [0, n-1] \) where \( n \) is the number of points of the curve.
Returns
index-th point of the curve
See also
getPointCount()

Implements gf::Curve.

virtual std::size_t gf::CompoundCurve::getPointCount ( ) const
overridevirtual

Get the total number of points of the curve.

Returns
Number of points of the curve
See also
getPoint()

Implements gf::Curve.

CompoundCurve& gf::CompoundCurve::lineTo ( Vector2f  p1)

Create a line from the last point to a new point.

Parameters
p1The new end point
CompoundCurve& gf::CompoundCurve::quadraticCurveTo ( Vector2f  p1,
Vector2f  p2,
std::size_t  pointCount = 20 
)

Create a quadratic Bézier curve from the last point to a new point.

Parameters
p1The control point
p2The new end point
pointCountThe number of points composing the curve
CompoundCurve& gf::CompoundCurve::setOrigin ( Vector2f  origin)

Set the first point of the curve.

Parameters
originThe first point of the curve
Returns
A reference on the current compound curve