HikoGUI
A low latency retained GUI
|
#include <hikogui/graphic_path/graphic_path.hpp>
Public Member Functions | |
void | clear () noexcept |
Clear the path. | |
ssize_t | numberOfContours () const noexcept |
Return the number of closed contours. | |
ssize_t | numberOfLayers () const noexcept |
Return the number of closed layers. | |
bool | allLayersHaveSameColor () const noexcept |
Check if all layers have the same color. | |
aarectangle | boundingBox () const noexcept |
Calculate bounding box. | |
void | tryRemoveLayers () noexcept |
Try to move the layers in a path. | |
std::vector< bezier_point >::const_iterator | beginContour (ssize_t contourNr) const noexcept |
Return an iterator to the start point of a contour. | |
std::vector< bezier_point >::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< bezier_point > | getbezier_pointsOfContour (ssize_t contourNr) const noexcept |
std::vector< bezier_curve > | getBeziersOfContour (ssize_t contourNr) const noexcept |
std::vector< bezier_curve > | getBeziers () const noexcept |
std::pair< graphic_path, color > | getLayer (ssize_t layerNr) const noexcept |
color | getColorOfLayer (ssize_t layerNr) const noexcept |
void | setColorOfLayer (ssize_t layerNr, color fill_color) noexcept |
bool | isContourOpen () const noexcept |
Return true if there is an open contour. | |
void | closeContour () noexcept |
Close current contour. | |
bool | hasLayers () const noexcept |
This path has layers. | |
bool | isLayerOpen () const noexcept |
Return true if there is an open layer. | |
void | closeLayer (color fill_color) noexcept |
Close current contour. | |
void | optimizeLayers () noexcept |
Optimize layers. | |
point2 | currentPosition () const noexcept |
Get the currentPosition of the open contour. | |
void | moveTo (point2 position) noexcept |
Start a new contour at position. | |
void | moveRelativeTo (vector2 direction) noexcept |
Start a new contour relative to current position. | |
void | lineTo (point2 position) noexcept |
void | lineRelativeTo (vector2 direction) noexcept |
void | quadraticCurveTo (point2 controlPosition, point2 position) noexcept |
void | quadraticCurveRelativeTo (vector2 controlDirection, vector2 direction) noexcept |
Draw curve from the current position to the new direction. | |
void | cubicCurveTo (point2 controlPosition1, point2 controlPosition2, point2 position) noexcept |
void | cubicCurveRelativeTo (vector2 controlDirection1, vector2 controlDirection2, vector2 direction) noexcept |
Draw curve from the current position to the new direction. | |
void | arcTo (float radius, point2 position) noexcept |
Draw an circular arc. | |
void | addRectangle (aarectangle rectangle, corner_radii corners=corner_radii{0.0f, 0.0f, 0.0f, 0.0f}) noexcept |
Draw a rectangle. | |
void | addCircle (point2 position, float radius) noexcept |
Draw a circle. | |
void | addContour (std::vector< bezier_curve > const &contour) noexcept |
Contour with the given bezier curves. | |
void | addContour (std::vector< bezier_point >::const_iterator const &begin, std::vector< bezier_point >::const_iterator const &end) noexcept |
Curve with the given bezier curve. | |
void | addContour (std::vector< bezier_point > const &contour) noexcept |
Curve with the given bezier curve. | |
void | addPath (graphic_path const &path, color fill_color) noexcept |
Add path and close layer. | |
void | addStroke (graphic_path const &path, color strokeColor, float strokeWidth, hi::line_join_style line_join_style=line_join_style::miter, float tolerance=0.05f) noexcept |
Stroke a path and close layer. | |
graphic_path | toStroke (float strokeWidth=1.0f, line_join_style line_join_style=line_join_style::miter, float tolerance=0.05f) const noexcept |
Convert path to stroke-path. | |
graphic_path | centerScale (extent2 extent, float padding=0.0) const noexcept |
Center and scale a path inside the extent with padding. | |
graphic_path & | operator+= (graphic_path const &rhs) noexcept |
Data Fields | |
std::vector< bezier_point > | points |
A set of all bezier points describing all bezier curves, contours and layers. | |
std::vector< ssize_t > | contourEndPoints |
An index into. | |
std::vector< std::pair< ssize_t, color > > | layerEndContours |
An color and index into. | |
Friends | |
graphic_path | operator+ (graphic_path lhs, graphic_path const &rhs) noexcept |
graphic_path | operator* (transformer2 auto const &lhs, graphic_path const &rhs) noexcept |
A path is a vector graphics object.
It represents:
|
inlinenoexcept |
Draw a circle.
position | position of the center of the circle. |
radius | radius of the circle |
|
inlinenoexcept |
Contour with the given bezier curves.
The first anchor will be ignored.
|
inlinenoexcept |
Curve with the given bezier curve.
The first anchor will be ignored.
|
inlinenoexcept |
Curve with the given bezier curve.
The first anchor will be ignored.
|
inlinenoexcept |
Add path and close layer.
|
inlinenoexcept |
Draw a rectangle.
rectangle | the offset and size of the rectangle. |
corners | The radius of the (bottom-left, bottom-right, top-left, top-right) positive corner are rounded, negative curves are cut. |
|
inlinenoexcept |
Stroke a path and close layer.
|
inlinenoexcept |
Check if all layers have the same color.
|
inlinenoexcept |
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 Riskus (chapter 3, formulas 8 and 9, there are a few typos in the formulas)
radius | positive radius means positive arc, negative radius is a negative arc. |
position | end position of the arc. |
|
inlinenoexcept |
Return an iterator to the start point of a contour.
|
inlinenoexcept |
Calculate bounding box.
|
inlinenoexcept |
Center and scale a path inside the extent with padding.
|
inlinenoexcept |
Clear the path.
|
inlinenoexcept |
Close current contour.
No operation if there is no open contour.
|
inlinenoexcept |
Close current contour.
No operation if there is no open layer.
|
inlinenoexcept |
Draw curve from the current position to the new direction.
controlDirection1 | The first control point of the curve relative from the start of the curve. |
controlDirection2 | The second control point of the curve relative from the start of the curve. |
direction | end point of the curve relative from the start of the curve. |
|
inlinenoexcept |
Get the currentPosition of the open contour.
Returns {0, 0} when there is no contour open.
|
inlinenoexcept |
This path has layers.
|
inlinenoexcept |
Return true if there is an open contour.
|
inlinenoexcept |
Return true if there is an open layer.
|
inlinenoexcept |
Start a new contour relative to current position.
closes current subpath.
|
inlinenoexcept |
Start a new contour at position.
closes current subpath.
|
inlinenoexcept |
Return the number of closed contours.
|
inlinenoexcept |
Return the number of closed layers.
|
inlinenoexcept |
Optimize layers.
Merge contiguous layers with the same color.
|
inlinenoexcept |
Draw curve from the current position to the new direction.
controlDirection | control point of the curve relative from the start of the curve. |
direction | end point of the curve relative from the start of the curve. |
|
inlinenoexcept |
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.
strokeWidth | width of the stroke. |
line_join_style | the style of how outside corners of a stroke are drawn. |
tolerance | Tolerance of how flat the curves in the path need to be. |
|
inlinenoexcept |
Try to move the layers in a path.
Layers are removed if there are layers, and all the layers have the same color.
std::vector<ssize_t> hi::v1::graphic_path::contourEndPoints |
An index into.
std::vector<std::pair<ssize_t, color> > hi::v1::graphic_path::layerEndContours |
An color and index into.
std::vector<bezier_point> hi::v1::graphic_path::points |
A set of all bezier points describing all bezier curves, contours and layers.