Kale
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | List of all members
Kale::Path Class Reference

#include <Path.hpp>

Public Member Functions

 Path ()
 
 Path (size_t n)
 
 Path (const std::vector< CubicBezier > &beziers)
 
 Path (const std::vector< Vector2f > &lines, float cornerRadius)
 
 Path (const std::vector< std::pair< Vector2f, float > > &lines)
 
Rect getBoundingBox () const
 
void operator+= (const Path &other)
 
Path operator* (float value) const
 
void moveTo (Vector2f pos)
 
void lineTo (Vector2f pos)
 
void bezierTo (Vector2f controlPoint1, Vector2f controlPoint2, Vector2f end)
 
void arcTo (Vector2f end, Vector2f center, bool clockwise)
 
void closePath ()
 

Public Attributes

std::vector< CubicBezierbeziers
 

Private Member Functions

void roundCorners (const std::vector< std::pair< Vector2f, float > > &lines)
 

Detailed Description

Represents a path of beziers

Definition at line 47 of file Path.hpp.

Constructor & Destructor Documentation

◆ Path() [1/5]

Path::Path ( )

Creates a new empty path

Definition at line 28 of file Path.cpp.

◆ Path() [2/5]

Path::Path ( size_t n)

Creates a path with a size with all points at 0

Parameters
nThe size

Definition at line 36 of file Path.cpp.

◆ Path() [3/5]

Path::Path ( const std::vector< CubicBezier > & beziers)

Creates a path given beziers

Parameters
beziersThe beziers

Definition at line 44 of file Path.cpp.

◆ Path() [4/5]

Path::Path ( const std::vector< Vector2f > & lines,
float cornerRadius )

Creates a path given a closed shape made of lines and a corner radius to use to round each corner of the shape

Parameters
linesA vector of the lines, each element has a line drawn to the next and the last element has a line drawn to the first
cornerRadiusThe corner radius to use to round the corners of the shape

Definition at line 53 of file Path.cpp.

◆ Path() [5/5]

Path::Path ( const std::vector< std::pair< Vector2f, float > > & lines)

Creates a path given a closed shape of lines, and a corner radius to use to round each corner of the shape

Parameters
linesA vector of the lines, each element has a line drawn to the next and the last element has a line drawn to the first. The second item in the pair is the corner radius to the corner created by the specific point, you can use a negative number or 0 to denote no corner rounding.

Definition at line 67 of file Path.cpp.

Member Function Documentation

◆ arcTo()

void Path::arcTo ( Vector2f end,
Vector2f center,
bool clockwise )

Creates an arc (a segment of a circle's circumference) to a point given a center

Note
Do not add beziers manually when using path modification methods
Parameters
endThe ending point where the arc ends
centerThe center of the circle of which the arc is drawn to
clockwiseWhether or not to draw the arc clockwise or counter clockwise to the ending position

Definition at line 230 of file Path.cpp.

◆ bezierTo()

void Path::bezierTo ( Vector2f controlPoint1,
Vector2f controlPoint2,
Vector2f end )

Moves the path to a new position while drawing a cubic bezier curve to the new position.

Note
Do not add beziers manually when using path modification methods
Parameters
controlPoint1The first control point of the bezier
controlPoint2The second control point of the bezier
endThe ending point of the bezier

Definition at line 216 of file Path.cpp.

◆ closePath()

void Path::closePath ( )

Closes the path allowing for rendering

Note
Do not add beziers manually when using path modification methods, this method closes off the path making it suitable for rendering

Definition at line 272 of file Path.cpp.

◆ getBoundingBox()

Rect Path::getBoundingBox ( ) const

Gets the bounding box for this path

Returns
The bounding box

Definition at line 141 of file Path.cpp.

◆ lineTo()

void Path::lineTo ( Vector2f pos)

Moves the path to a new position while drawing a line to the new position.

Note
Do not add beziers manually when using path modification methods
Parameters
posThe position to draw a line to

Definition at line 202 of file Path.cpp.

◆ moveTo()

void Path::moveTo ( Vector2f pos)

Moves the starting point of the path to a certain point.

Note
This function must be used when there are no beziers in the path, and other path modification methods must be used directly after.
Parameters
posThe position to move to

Definition at line 192 of file Path.cpp.

◆ operator*()

Path Path::operator* ( float value) const

Multiplies this path's points by a value

Parameters
valueThe scalar value

Definition at line 175 of file Path.cpp.

◆ operator+=()

void Path::operator+= ( const Path & other)

Adds another path to this

Parameters
otherThe path to add to this

Definition at line 161 of file Path.cpp.

◆ roundCorners()

void Path::roundCorners ( const std::vector< std::pair< Vector2f, float > > & lines)
private

Creates a path with rounded corners

Parameters
linesThe lines to create the path from

Definition at line 75 of file Path.cpp.

Member Data Documentation

◆ beziers

std::vector<CubicBezier> Kale::Path::beziers

The beziers held in this path

Definition at line 61 of file Path.hpp.


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