Describes lines and curves that are more complex than simple rectangles.
Paths can used for rendering (filling or stroking) and for animations (e.g. as trajectories).
GskPath is an immutable, opaque, reference-counted struct. After creation, you cannot change the types it represents. Instead, new GskPath objects have to be created. The [structGsk.PathBuilder] structure is meant to help in this endeavor.
Conceptually, a path consists of zero or more contours (continuous, connected curves), each of which may or may not be closed. Contours are typically constructed from Bézier segments.
<picture> <source srcset="path-dark.png" media="(prefers-color-scheme: dark)"> <img alt="A Path" src="path-light.png"> </picture> <gtkada_demo>create_paths.adb</gtkada_demo>
function Equal (Self : Gsk_Path; Path2 : Gsk_Path) return Boolean
Returns whether two paths have identical structure. Note that it is possible to construct paths that render identical even though they don't have the same structure. Since: gtk+ 4.22
another path
true if Path1 and Path2 have identical structure
function Foreach
(Self : Gsk_Path; Flags : Gsk.Enums.Gsk_Path_Foreach_Flags;
Func : Gsk_Path_Foreach_Func;
User_Data : System.Address := System.Null_Address) return Boolean
function From_Object (Object : System.Address) return Gsk_Path
function From_Object_Free (B : access Gsk_Path'Class) return Gsk_Path
function Get_Bounds
(Self : Gsk_Path;
Bounds : not null access Graphene.Rect.Graphene_Rect_T)
return Boolean
Computes the bounds of the given path. The returned bounds may be larger than necessary, because this function aims to be fast, not accurate. The bounds are guaranteed to contain the path. For accurate bounds, use [methodGsk.Path.get_tight_bounds]. It is possible that the returned rectangle has 0 width and/or height. This can happen when the path only describes a point or an axis-aligned line. If the path is empty, false is returned and Bounds are set to Graphene.Rect.Zero. This is different from the case where the path is a single point at the origin, where the Bounds will also be set to the zero rectangle but true will be returned. Since: gtk+ 4.14
return location for the bounds
true if the path has bounds, false if the path is known to be empty and have no bounds
function Get_Closest_Point
(Self : Gsk_Path;
Point : not null access Graphene.Point.Graphene_Point_T;
Threshold : Interfaces.C.C_float;
Result : not null access Gsk.Path_Point.Gsk_Path_Point;
Distance : access Interfaces.C.C_float := null) return Boolean
Computes the closest point on the path to the given point. If there is no point closer than the given threshold, false is returned. Since: gtk+ 4.14
the point
maximum allowed distance
return location for the closest point
return location for the distance
true if Point was set to the closest point on Self, false if no point is closer than Threshold
function Get_End_Point
(Self : Gsk_Path;
Result : not null access Gsk.Path_Point.Gsk_Path_Point)
return Boolean
Gets the end point of the path. An empty path has no points, so false is returned in this case. Since: gtk+ 4.14
return location for point
true if Result was filled
function Get_Next
(Self : Gsk_Path;
Point : in out Gsk.Path_Point.Gsk_Path_Point) return Boolean
Moves Point to the next vertex. An empty path has no points, so false is returned in this case. Since: gtk+ 4.22
the current point
true if Point was set
function Get_Previous
(Self : Gsk_Path;
Point : in out Gsk.Path_Point.Gsk_Path_Point) return Boolean
Moves Point to the previous vertex. An empty path has no points, so false is returned in this case. Since: gtk+ 4.22
the current point
true if Point was set
function Get_Start_Point
(Self : Gsk_Path;
Result : not null access Gsk.Path_Point.Gsk_Path_Point)
return Boolean
Gets the start point of the path. An empty path has no points, so false is returned in this case. Since: gtk+ 4.14
return location for point
true if Result was filled
function Get_Stroke_Bounds
(Self : Gsk_Path;
Stroke : Gsk.Stroke.Gsk_Stroke;
Bounds : not null access Graphene.Rect.Graphene_Rect_T)
return Boolean
Computes the bounds for stroking the given path with the given parameters. The returned bounds may be larger than necessary, because this function aims to be fast, not accurate. The bounds are guaranteed to contain the area affected by the stroke, including protrusions like miters. Since: gtk+ 4.14
stroke parameters
the bounds to fill in
true if the path has bounds, false if the path is known to be empty and have no bounds.
function Get_Tight_Bounds
(Self : Gsk_Path;
Bounds : not null access Graphene.Rect.Graphene_Rect_T)
return Boolean
Computes the tight bounds of the given path. This function works harder than [methodGsk.Path.get_bounds] to produce the smallest possible bounds. Since: gtk+ 4.22
return location for the bounds
true if the path has bounds, false if the path is known to be empty and have no bounds
function Get_Type return Glib.GType
type Gsk_Path is new Glib.C_Boxed with null record;
type Gsk_Path_Foreach_Func is access function
(Op : Gsk.Enums.Gsk_Path_Operation;
Points : access constant Graphene.Point.Graphene_Point_T;
N_Points : Gsize; Weight : Interfaces.C.C_float;
User_Data : System.Address) return Gboolean;
Points is a borrowed C array with N_Points elements, valid during the callback only. Return False (0) to stop iteration.
function In_Fill
(Self : Gsk_Path;
Point : not null access Graphene.Point.Graphene_Point_T;
Fill_Rule : Gsk.Enums.Gsk_Fill_Rule) return Boolean
Returns whether a point is inside the fill area of a path. Note that this function assumes that filling a contour implicitly closes it. Since: gtk+ 4.14
the point to test
the fill rule to follow
true if Point is inside
function Is_Closed (Self : Gsk_Path) return Boolean
Returns if the path represents a single closed contour. Since: gtk+ 4.14
true if the path is closed
function Is_Empty (Self : Gsk_Path) return Boolean
Checks if the path is empty, i.e. contains no lines or curves. Since: gtk+ 4.14
true if the path is empty
Null_Gsk_Path : constant Gsk_Path;
function Parse (String : UTF8_String) return Gsk_Path
Constructs a path from a serialized form. The string is expected to be in (a superset of) SVG path syntax, as e.g. produced by [methodGsk.Path.to_string]. A high-level summary of the syntax:
M x y Move to (x, y) - L x y Add a line from the current point
to (x, y) - Q x1 y1 x2 y2 Add a quadratic Bézier from the current point to (x2, y2), with control point (x1, y1) - C x1 y1 x2 y2 x3 y3 Add a cubic Bézier from the current point to (x3, y3), with control points (x1, y1) and (x2, y2) - Z Close the contour by drawing a line back to the start point - H x Add a horizontal line from the current point to the given x value - V y Add a vertical line from the current point to the given y value - T x2 y2 Add a quadratic Bézier, using the reflection of the previous segments' control point as control point - S x2 y2 x3 y3 Add a cubic Bézier, using the reflection of the previous segments' second control point as first control point - A rx ry r l s x y Add an elliptical arc from the current point to (x, y) with radii rx and ry. See the SVG documentation for how the other parameters influence the arc. - O x1 y1 x2 y2 w Add a rational quadratic Bézier from the current point to (x2, y2) with control point (x1, y1) and weight w. All the commands have lowercase variants that interpret coordinates relative to the current point. The O command is an extension that is not supported in SVG. Since: gtk+ 4.14
a string
a new GskPath, or NULL if String could not be parsed. Has transfer-ownership='full'.
procedure Print (Self : Gsk_Path; String : Glib.String.Gstring)
Converts the path into a human-readable representation. The string is compatible with (a superset of) SVG path syntax, see [funcGsk.Path.parse] for a summary of the syntax. Since: gtk+ 4.14
the string to print into
function Ref (Self : Gsk_Path) return Gsk_Path
Increases the reference count of a path by one. Since: gtk+ 4.14
the passed in GskPath. Has transfer-ownership='full'.
procedure To_Cairo (Self : Gsk_Path; Cr : Cairo.Cairo_Context)
Appends the path to a cairo context for drawing with Cairo. This may cause some suboptimal conversions to be performed as Cairo does not support all features of GskPath. This function does not clear the existing Cairo path. Call cairo_new_path if you want this. Since: gtk+ 4.14
a cairo context
function To_String (Self : Gsk_Path) return UTF8_String
Converts the path into a human-readable string. You can use this function in a debugger to get a quick overview of the path. This is a wrapper around [methodGsk.Path.print], see that function for details. Since: gtk+ 4.14
a new string for Self
procedure Unref (Self : Gsk_Path)
Decreases the reference count of a path by one. If the resulting reference count is zero, frees the path. Since: gtk+ 4.14