Path
-
class Path
General-purpose 2D vector path.
A path is a sequence of verbs (move, line, quad, cubic, conic, close) and associated control points. Paths can be filled or stroked.
Path building
Relative building commands
Convenience shape builders
-
Path &addRect(Rect r, PathDirection dir = PathDirection::CW)
-
Path &addOval(Rect bounds, PathDirection dir = PathDirection::CW)
-
Path &addCircle(f32 cx, f32 cy, f32 radius, PathDirection dir = PathDirection::CW)
-
Path &addRoundRect(Rect r, f32 rx, f32 ry, PathDirection dir = PathDirection::CW)
Accessors
-
inline const std::vector<f32> &conicWeights() const
-
bool contains(Point p) const
Return true if the point is inside the path using the current fill rule.
-
inline bool contains(f32 x, f32 y) const
-
bool getDirection(PathDirection *direction) const
Compute the dominant winding direction of the path.
- Returns:
False for empty or degenerate paths with no measurable area.
-
PathDirection direction() const
Return the dominant winding direction, defaulting to CW for degenerate paths.
-
inline bool isEmpty() const
-
inline i32 countVerbs() const
-
inline i32 countPoints() const
-
bool isConvex() const
Public Types
-
enum class Verb : u8
Values:
-
enumerator Move
Start a new contour (1 point).
-
enumerator Line
Line segment (1 point — endpoint).
-
enumerator Quad
Quadratic Bezier (2 points — control, end).
-
enumerator Cubic
Cubic Bezier (3 points — control1, control2, end).
-
enumerator Conic
Conic (rational quadratic, 2 points + weight).
-
enumerator Close
Close current contour (0 points).
-
enumerator Move
Public Functions
-
Path() = default
-
Path &addRect(Rect r, PathDirection dir = PathDirection::CW)
-
enum class ink::FillRule : u8
Fill rule for path rendering.
Values:
-
enumerator Winding
Non-zero winding rule.
-
enumerator EvenOdd
Even-odd (parity) rule.
-
enumerator Winding
-
enum class ink::PathDirection : u8
Winding direction for shape builders.
Values:
-
enumerator CW
Clockwise.
-
enumerator CCW
Counter-clockwise.
-
enumerator CW
-
enum class ink::LineCap : u8
Line cap style for stroked paths.
Values:
-
enumerator Butt
Flat cap at the endpoint.
-
enumerator Round
Semicircular cap.
-
enumerator Square
Extended flat cap (half stroke width).
-
enumerator Butt
-
enum class ink::LineJoin : u8
Line join style for stroked paths.
Values:
-
enumerator Miter
Sharp corner (extended to miter limit).
-
enumerator Round
Rounded corner.
-
enumerator Bevel
Flat corner.
-
enumerator Miter
-
class PathEffect
Abstract path effect that transforms geometry before drawing.
-
namespace PathEffects
Factory functions for creating path effects.
Functions
-
std::shared_ptr<PathEffect> MakeDash(const f32 *intervals, i32 count, f32 phase = 0.0f)
Create a dash effect from alternating on/off intervals.
- Parameters:
intervals – Positive interval lengths. Odd counts are repeated to form an even pattern.
count – Number of interval entries.
phase – Initial distance into the pattern.
- Returns:
Shared pointer to the effect, or nullptr for invalid intervals.
-
std::shared_ptr<PathEffect> MakeDash(const f32 *intervals, i32 count, f32 phase = 0.0f)