sf-svg
Public Member Functions | Protected Attributes | List of all members
sfc::BezierAbstractCurve Class Referenceabstract

Abstract Bezier curve class. More...

#include <BezierAbstractCurve.hpp>

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

Public Member Functions

virtual Line2< float > getHelperLine (const float) const =0
 Get last line used to draw a curve. More...
 
virtual void update ()=0
 Calculates vertices. More...
 
virtual std::size_t getPointCount () const
 Returns point count.
 
virtual sf::Vector2f getPoint (std::size_t) const =0
 Get n-th point of curve. More...
 
virtual ~BezierAbstractCurve ()
 Virtual destructor. More...
 
virtual void calculateVeritces (std::vector< sf::Vector2f > &vector, const float limitCurve, sf::Vertex *debugLines)=0
 Calculate points on cuve. 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 Attributes

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

Abstract Bezier curve class.

Do not define methods!
Inherit it to create class compatibile with Brezier Curve API.
Remember, it's not an interface, this class contains variables and some definied methods – getters & setters (mostly).

Constructor & Destructor Documentation

◆ ~BezierAbstractCurve()

virtual sfc::BezierAbstractCurve::~BezierAbstractCurve ( )
inlinevirtual

Virtual destructor.

Does nothing expect of ensuring that destructors of inherited classes will be called.

Member Function Documentation

◆ calculateVeritces()

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

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.

Implemented in sfc::BezierCubicCurve, and sfc::BezierSquareCurve.

◆ getHelperLine()

virtual Line2<float> sfc::BezierAbstractCurve::getHelperLine ( const float  ) const
pure 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.

Implemented in sfc::BezierCubicCurve, and sfc::BezierSquareCurve.

◆ getNormalizedLengthLimit()

float sfc::BezierAbstractCurve::getNormalizedLengthLimit ( )

Get part of curve to be drawn.

Take a look at setNormalizedLengthLimit() and m_limitCurve.

◆ getPoint()

virtual sf::Vector2f sfc::BezierAbstractCurve::getPoint ( std::size_t  ) const
pure virtual

Get n-th point of curve.

Parameters
[in]index– point index

Implemented in sfc::BezierCubicCurve, and sfc::BezierSquareCurve.

◆ setColor()

void sfc::BezierAbstractCurve::setColor ( const sf::Color &  color)

Sets color.

Parameters
[in]color– New color

Use to set color of curve's vertices.

curve.setColor({255, 20, 20}); //Red

◆ setNormalizedLengthLimit()

void sfc::BezierAbstractCurve::setNormalizedLengthLimit ( const float  limit)

Set part of curve to be drawn.

Parameters
[in]normalized– part of curve to be drawn in range [0, 1]
curve.setNormalizedLengthLimit(.5f); //Draw 50% of the curve

◆ setPointCount()

void sfc::BezierAbstractCurve::setPointCount ( const std::size_t  count)

Set amount of points to draw curve.

Parameters
[in]count– Amount of points to use
curve1.setPointCount(6); //Ugly one
curve12.setPointCount(200); //OK in most cases
curve2.setPointCount(6000); //Sooo good (actually too much)

◆ update()

virtual void sfc::BezierAbstractCurve::update ( )
pure 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);

Implemented in sfc::BezierCubicCurve, and sfc::BezierSquareCurve.

Member Data Documentation

◆ m_limitCurve

float sfc::BezierAbstractCurve::m_limitCurve
protected

Part of curve to be drawn.

Real number in range [0, 1], if set to .5 only 50% of curve will be drawn etc.

◆ m_mode

DrawMode sfc::BezierAbstractCurve::m_mode
protected

Drawing mode.

NORMAL – Just draw curve
DEBUG – Draw also helper lines etc.


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