HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Friends
tt::Path Struct Reference

#include <TTauri/Foundation/Path.hpp>

Public Member Functions

void clear () noexcept
 Clear the path.
 
ssize_t numberOfContours () const noexcept
 
ssize_t numberOfLayers () const noexcept
 
bool allLayersHaveSameColor () const noexcept
 
aarect boundingBox () const noexcept
 Calculate bounding box.
 
void tryRemoveLayers () noexcept
 
std::vector< BezierPoint >::const_iterator beginContour (ssize_t contourNr) const noexcept
 
std::vector< BezierPoint >::const_iterator endContour (ssize_t contourNr) const noexcept
 
ssize_t beginLayer (ssize_t layerNr) const noexcept
 
ssize_t endLayer (ssize_t layerNr) const noexcept
 
std::vector< BezierPointgetBezierPointsOfContour (ssize_t contourNr) const noexcept
 
std::vector< BezierCurvegetBeziersOfContour (ssize_t contourNr) const noexcept
 
std::vector< BezierCurvegetBeziers () const noexcept
 
std::pair< Path, vecgetLayer (ssize_t layerNr) const noexcept
 
vec getColorOfLayer (ssize_t layerNr) const noexcept
 
void setColorOfLayer (ssize_t layerNr, vec fillColor) noexcept
 
bool isContourOpen () const noexcept
 
void closeContour () noexcept
 
bool hasLayers () const noexcept
 
bool isLayerOpen () const noexcept
 
void closeLayer (vec fillColor) noexcept
 
void optimizeLayers () noexcept
 Optimize layers.
 
vec currentPosition () const noexcept
 
void moveTo (vec position) noexcept
 
void moveRelativeTo (vec direction) noexcept
 
void lineTo (vec position) noexcept
 
void lineRelativeTo (vec direction) noexcept
 
void quadraticCurveTo (vec controlPosition, vec position) noexcept
 
void quadraticCurveRelativeTo (vec controlDirection, vec direction) noexcept
 
void cubicCurveTo (vec controlPosition1, vec controlPosition2, vec position) noexcept
 
void cubicCurveRelativeTo (vec controlDirection1, vec controlDirection2, vec direction) noexcept
 
void arcTo (float radius, vec position) noexcept
 
void addRectangle (aarect r, vec corners={0.0f, 0.0f, 0.0f, 0.0f}) noexcept
 
void addCircle (vec position, float radius) noexcept
 
void addContour (std::vector< BezierCurve > const &contour) noexcept
 
void addContour (std::vector< BezierPoint >::const_iterator const &begin, std::vector< BezierPoint >::const_iterator const &end) noexcept
 
void addContour (std::vector< BezierPoint > const &contour) noexcept
 
void addPath (Path const &path, vec fillColor) noexcept
 
void addStroke (Path const &path, vec strokeColor, float strokeWidth, LineJoinStyle lineJoinStyle=LineJoinStyle::Miter, float tolerance=0.05f) noexcept
 
Path toStroke (float strokeWidth=1.0f, LineJoinStyle lineJoinStyle=LineJoinStyle::Miter, float tolerance=0.05f) const noexcept
 
Path centerScale (vec extent, float padding=0.0) const noexcept
 Center and scale a path inside the extent with padding.
 
Pathoperator+= (Path const &rhs) noexcept
 
template<typename M , std::enable_if_t< is_mat_v< M >, int > = 0>
Pathoperator*= (M const &rhs) noexcept
 

Data Fields

std::vector< BezierPointpoints
 
std::vector< ssize_tcontourEndPoints
 
std::vector< std::pair< ssize_t, vec > > layerEndContours
 

Friends

Path operator+ (Path lhs, Path const &rhs) noexcept
 
template<typename M , std::enable_if_t< is_mat_v< M >, int > = 0>
Path operator* (M const &lhs, Path rhs) noexcept
 

Detailed Description

A path is a vector graphics object. It represents:

Member Function Documentation

◆ addCircle()

void tt::Path::addCircle ( vec position,
float radius )
noexcept

Draw a circle.

Parameters
positionposition of the center of the circle.
radiusradius of the circle

◆ addContour() [1/3]

void tt::Path::addContour ( std::vector< BezierCurve > const & contour)
noexcept

Contour with the given bezier curves. The first anchor will be ignored.

◆ addContour() [2/3]

void tt::Path::addContour ( std::vector< BezierPoint > const & contour)
noexcept

Curve with the given bezier curve. The first anchor will be ignored.

◆ addContour() [3/3]

void tt::Path::addContour ( std::vector< BezierPoint >::const_iterator const & begin,
std::vector< BezierPoint >::const_iterator const & end )
noexcept

Curve with the given bezier curve. The first anchor will be ignored.

◆ addPath()

void tt::Path::addPath ( Path const & path,
vec fillColor )
noexcept

Add path and close layer.

◆ addRectangle()

void tt::Path::addRectangle ( aarect r,
vec corners = {0.0f, 0.0f, 0.0f, 0.0f} )
noexcept

Draw a rectangle.

Parameters
aarectthe offset and size of the rectangle.
cornerradius of <bottom-left, bottom-right, top-left, top-right> positive corner are rounded, negative curves are cut.

◆ addStroke()

void tt::Path::addStroke ( Path const & path,
vec strokeColor,
float strokeWidth,
LineJoinStyle lineJoinStyle = LineJoinStyle::Miter,
float tolerance = 0.05f )
noexcept

Stroke a path and close layer.

◆ allLayersHaveSameColor()

bool tt::Path::allLayersHaveSameColor ( ) const
noexcept

Check if all layers have the same color.

◆ arcTo()

void tt::Path::arcTo ( float radius,
vec position )
noexcept

Draw an circular arc. The arc is drawn from the current position to the position given in this method. A positive arc is drawn counter-clockwise.

Using method in: "Approximation of a cubic bezier curve by circular arcs and vice versa" – Aleksas Riškus (chapter 3, formulas 8 and 9, there are a few typos in the formulas)

Parameters
radiuspositive radius means positive arc, negative radius is a negative arc.
positionend position of the arc.

◆ beginContour()

std::vector< BezierPoint >::const_iterator tt::Path::beginContour ( ssize_t contourNr) const
noexcept

Return an iterator to the start point of a contour.

◆ boundingBox()

aarect tt::Path::boundingBox ( ) const
noexcept

Calculate bounding box.

◆ centerScale()

Path tt::Path::centerScale ( vec extent,
float padding = 0.0 ) const
noexcept

Center and scale a path inside the extent with padding.

◆ clear()

void tt::Path::clear ( )
inlinenoexcept

Clear the path.

◆ closeContour()

void tt::Path::closeContour ( )
noexcept

Close current contour. No operation if there is no open contour.

◆ closeLayer()

void tt::Path::closeLayer ( vec fillColor)
noexcept

Close current contour. No operation if there is no open layer.

◆ cubicCurveRelativeTo()

void tt::Path::cubicCurveRelativeTo ( vec controlDirection1,
vec controlDirection2,
vec direction )
noexcept

Draw curve from the current position to the new direction.

Parameters
controlDirectioncontrol point of the curve relative from the start of the curve.
directionend point of the curve relative from the start of the curve.

◆ currentPosition()

vec tt::Path::currentPosition ( ) const
noexcept

Get the currentPosition of the open contour. Returns {0, 0} when there is no contour open.

◆ hasLayers()

bool tt::Path::hasLayers ( ) const
noexcept

This path has layers.

◆ isContourOpen()

bool tt::Path::isContourOpen ( ) const
noexcept

Return true if there is an open contour.

◆ isLayerOpen()

bool tt::Path::isLayerOpen ( ) const
noexcept

Return true if there is an open layer.

◆ moveRelativeTo()

void tt::Path::moveRelativeTo ( vec direction)
noexcept

Start a new contour relative to current position. closes current subpath.

◆ moveTo()

void tt::Path::moveTo ( vec position)
noexcept

Start a new contour at position. closes current subpath.

◆ numberOfContours()

ssize_t tt::Path::numberOfContours ( ) const
noexcept

Return the number of closed contours.

◆ numberOfLayers()

ssize_t tt::Path::numberOfLayers ( ) const
noexcept

Return the number of closed layers.

◆ optimizeLayers()

void tt::Path::optimizeLayers ( )
noexcept

Optimize layers.

Merge contiguous layers with the same color.

◆ quadraticCurveRelativeTo()

void tt::Path::quadraticCurveRelativeTo ( vec controlDirection,
vec direction )
noexcept

Draw curve from the current position to the new direction.

Parameters
controlDirectioncontrol point of the curve relative from the start of the curve.
directionend point of the curve relative from the start of the curve.

◆ toStroke()

Path tt::Path::toStroke ( float strokeWidth = 1.0f,
LineJoinStyle lineJoinStyle = LineJoinStyle::Miter,
float tolerance = 0.05f ) const
noexcept

Convert path to stroke-path.

This function will create contours that are offset from the original path which creates a stroke. The path will first be subdivided until the curves are mostly flat, then the curves are converted into lines and offset, then the lines are connected to each other.

Parameters
strokeWidthwidth of the stroke.
lineJoinStylethe style of how outside corners of a stroke are drawn.
toleranceTolerance of how flat the curves in the path need to be.

◆ tryRemoveLayers()

void tt::Path::tryRemoveLayers ( )
noexcept

Try to move the layers in a path. Layers are removed if there are layers, and all the layers have the same color.

Field Documentation

◆ contourEndPoints

std::vector<ssize_t> tt::Path::contourEndPoints

An index into

See also
points where each contour ends.

◆ layerEndContours

std::vector<std::pair<ssize_t,vec> > tt::Path::layerEndContours

An color and index into

See also
contourEndPoints where each layer ends.

◆ points

std::vector<BezierPoint> tt::Path::points

A set of all bezier points describing all bezier curves, contours and layers.


The documentation for this struct was generated from the following file: