Bezier cubic curve representation.
More...
#include <BezierCubicCurve.hpp>
|
virtual void | calculateVeritces (std::vector< sf::Vector2f > &, const float, sf::Vertex *) |
| Calculate points on cuve. More...
|
|
Bezier cubic curve representation.
Can be drawn, inherits BezierAbstractCurve.
Use to draw/calculate more complex curves, like entities paths.
◆ 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.
|
◆ 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.
◆ 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 |
◆ getPointPosition()
Gets position of selected point.
- Parameters
-
[in] | point | – point type (PointType enum) |
- Returns
- sf::Vector2f (position)
◆ setPointPosition()
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.
curve.update();
curve.setColor({68, 69, 70});
window.draw(curve);
Implements sfc::BezierAbstractCurve.
The documentation for this class was generated from the following files: