sf-svg
Public Types | Public Member Functions | Protected Member Functions | List of all members
sfc::BezierCubicCurve Class Reference

Bezier cubic curve representation. More...

#include <BezierCubicCurve.hpp>

Inheritance diagram for sfc::BezierCubicCurve:
Inheritance graph
[legend]

Public Types

enum  PointType { BEGIN_CONTROL, END_CONTROL, BEGIN, END }
 Point type enum. More...
 

Public Member Functions

 BezierCubicCurve ()
 Default constructor. More...
 
 BezierCubicCurve (const sf::Vector2f &, const sf::Vector2f &, const sf::Vector2f &, const sf::Vector2f &, DrawMode=DrawMode::NORMAL)
 Specialized constructor. More...
 
virtual Line2< float > getHelperLine (const float) const
 Get last line used to draw a curve. More...
 
virtual sf::Vector2f getPoint (std::size_t) const
 Get n-th point of curve. More...
 
virtual void update ()
 Calculates vertices. More...
 
void setPointPosition (PointType, sf::Vector2f)
 Sets position of selected point. More...
 
sf::Vector2f getPointPosition (PointType)
 Gets position of selected point. More...
 
Line2< float > getCubicHelperLine1 (const float)
 Gets 1st helper line used to draw curve. More...
 
Line2< float > getCubicHelperLine2 (const float)
 Gets 2nd helper line used to draw curve. More...
 
- Public Member Functions inherited from sfc::BezierAbstractCurve
virtual std::size_t getPointCount () const
 Returns point count.
 
virtual ~BezierAbstractCurve ()
 Virtual destructor. More...
 
void setColor (const sf::Color &)
 Sets color. More...
 
sf::Color getColor ()
 Returns color of curve.
 
void setNormalizedLengthLimit (const float)
 Set part of curve to be drawn. More...
 
float getNormalizedLengthLimit ()
 Get part of curve to be drawn. More...
 
void setPointCount (const std::size_t)
 Set amount of points to draw curve. More...
 
void move (sf::Vector2f)
 Translate curve.
 
void scale (const sf::Vector2f &factor)
 Scale curve.
 

Protected Member Functions

virtual void calculateVeritces (std::vector< sf::Vector2f > &, const float, sf::Vertex *)
 Calculate points on cuve. More...
 

Additional Inherited Members

- Protected Attributes inherited from sfc::BezierAbstractCurve
VertexVector< sf::LinesStrip > m_vertices
 Vertices used to draw curve.
 
std::size_t m_pointCount
 Stores points count.
 
sf::Color m_color
 Curve's color.
 
sf::Vector2f m_begin
 First point of a curve.
 
sf::Vector2f m_end
 Last point of a curve.
 
float m_limitCurve
 Part of curve to be drawn. More...
 
DrawMode m_mode
 Drawing mode. More...
 

Detailed Description

Bezier cubic curve representation.

Can be drawn, inherits BezierAbstractCurve.
Use to draw/calculate more complex curves, like entities paths.

Member Enumeration Documentation

◆ PointType

Point type enum.

Used to easly set/get points with one function – setPointPosition / getPointPosition.

Enumerator
BEGIN_CONTROL 

First control point.

END_CONTROL 

Second control point.

BEGIN 

Beginning of the curve.

END 

End of the curve.

Constructor & Destructor Documentation

◆ BezierCubicCurve() [1/2]

sfc::BezierCubicCurve::BezierCubicCurve ( )

Default constructor.

Sets point count to 32 and color to white.

◆ BezierCubicCurve() [2/2]

sfc::BezierCubicCurve::BezierCubicCurve ( const sf::Vector2f &  start,
const sf::Vector2f &  end,
const sf::Vector2f &  startControl,
const sf::Vector2f &  endControl,
DrawMode  mode = DrawMode::NORMAL 
)

Specialized constructor.

Parameters
[in]start– beginning of the curve
[in]end– end of the curve
[in]startControl– first control point
[in]endControl– second control point

Sets point count to 32 and color to white. Calls calculateCubic with proper args.

Member Function Documentation

◆ calculateVeritces()

void sfc::BezierCubicCurve::calculateVeritces ( std::vector< sf::Vector2f > &  vector,
const float  limitCurve,
sf::Vertex *  debugLines 
)
protectedvirtual

Calculate points on cuve.

Parameters
[out]vector– vector to store vertices
[in]limitCurve– part of curve to be drawn, range [0, 1]
[out]debugLines– vertex array, used to store and draw helper lines

Calculates all curve-related things like vertices positions / helper lines etc. Not a big deal, use only if you really want to inherit BezierCubicCurve.

Implements sfc::BezierAbstractCurve.

◆ getCubicHelperLine1()

Line2< float > sfc::BezierCubicCurve::getCubicHelperLine1 ( const float  normalized)

Gets 1st helper line used to draw curve.

Parameters
[in]normalized– Normalized ([0, 1]) progress

◆ getCubicHelperLine2()

Line2< float > sfc::BezierCubicCurve::getCubicHelperLine2 ( const float  normalized)

Gets 2nd helper line used to draw curve.

Parameters
[in]normalized– Normalized ([0, 1]) progress

◆ getHelperLine()

Line2< float > sfc::BezierCubicCurve::getHelperLine ( const float  ) const
virtual

Get last line used to draw a curve.

Parameters
[in]normalized– progress of drawing curve in range [0, 1]

Other helper lines are ignored, this function returns the one, on which "pencil" is placed.

Implements sfc::BezierAbstractCurve.

◆ getPoint()

sf::Vector2f sfc::BezierCubicCurve::getPoint ( std::size_t  ) const
virtual

Get n-th point of curve.

Parameters
[in]index– point index

Implements sfc::BezierAbstractCurve.

◆ getPointPosition()

sf::Vector2f sfc::BezierCubicCurve::getPointPosition ( BezierCubicCurve::PointType  point)

Gets position of selected point.

Parameters
[in]point– point type (PointType enum)
Returns
sf::Vector2f (position)

◆ setPointPosition()

void sfc::BezierCubicCurve::setPointPosition ( BezierCubicCurve::PointType  point,
sf::Vector2f  pos 
)

Sets position of selected point.

Parameters
[in]point– point type (PointType enum)
[in]pos– new position

◆ update()

void sfc::BezierCubicCurve::update ( )
virtual

Calculates vertices.

Changes are applied only when this function is called.

sfc::BezierCubicCurve curve(arg1, arg2, arg3, arg4);
curve.update();
//...
curve.setColor({68, 69, 70}); //Ignored
window.draw(curve);

Implements sfc::BezierAbstractCurve.


The documentation for this class was generated from the following files: