Constructs GskPath objects. A path is constructed like this: c GskPath * construct_path (void) { GskPathBuilder *builder; builder = gsk_path_builder_new (); // add contours to the path here return gsk_path_builder_free_to_path (builder); Adding contours to the path can
be done in two ways. The easiest option is to use the
gsk_path_builder_add_* group of functions that add predefined contours to
the current path, either common shapes like
[method@Gsk.PathBuilder.add_circle] or by adding from other paths like
[method@Gsk.PathBuilder.add_path]. The gsk_path_builder_add_* methods
always add complete contours, and do not use or modify the current point. The
other option is to define each line and curve manually with the
gsk_path_builder_*_to group of functions. You start with a call to
[method@Gsk.PathBuilder.move_to] to set the starting point and then use
multiple calls to any of the drawing functions to move the pen along the
plane. Once you are done, you can call [method@Gsk.PathBuilder.close] to
close the path by connecting it back with a line to the starting point. This
is similar to how paths are drawn in Cairo. Note that GskPathBuilder will
reduce the degree of added Bézier curves as much as possible, to simplify
rendering.
Members
handleObj
lib
retainedCallbacks
signalHandlerNames
signalSetterHandlers
Methods
GskPathBuilder (Handle = null)
Create a new GskPathBuilder object. The resulting builder would create an empty GskPath. Use addition functions to add types to it.
@pHandle is an optional native handle or wrapper whose handle to adopt; when the native constructor is called.
toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.
@pSource is the raw handle, raw buffer, wrapper, or null.
@rA raw pointer carrier or null when no pointer is present.
getLib ()
Returns the opened native library for this generated wrapper.
@rThe opened native library.
handle ()
Returns the wrapped NativeHandle.
@rThe wrapped NativeHandle.
isNull ()
Returns true when the wrapped handle is null.
@rA bool.
describe ()
Returns a small string for debugging generated wrappers.
@rA string.
add_cairo_path (object path)
Adds a Cairo path to the builder. You can use cairo_copy_path() to access the path from a Cairo context.
@ppath is a path.
@rNone.
add_circle (object center, double radius)
Adds a circle as a new contour. The path is going around the circle in clockwise direction. If @radius is zero, the contour will be a closed point.
@pcenter is the center of the circle.
@pradius is the radius of the circle.
@rNone.
add_layout (object layout)
Adds the outlines for the glyphs in @layout to the builder.
@playout is the pango layout to add.
@rNone.
add_path (object path)
Appends all of @path to the builder.
@ppath is the path to append.
@rNone.
add_rect (object rect)
Adds a rectangle as a new contour. The path is going around the rectangle in clockwise direction. If the the width or height are 0, the path will be a closed horizontal or vertical line. If both are 0, it'll be a closed dot.
@prect is the rectangle to create a path for.
@rNone.
add_reverse_path (object path)
Appends all of @path to the builder, in reverse order.
@ppath is the path to append.
@rNone.
add_rounded_rect (object rect)
Adds a rounded rectangle as a new contour. The path is going around the rectangle in clockwise direction.
Adds a segment of a path to the builder. If @start is equal to or after
@end,the path will first add the segment from @start to the end of the path, and then add the segment from the beginning to @end. If the path is closed, these segments will be connected. Note that this method always adds a path with the given start point and end point. To add a closed path, use [method@Gsk.PathBuilder.add_path].
Adds an elliptical arc from the current point to @x2, @y2 with @x1, @y1 determining the tangent directions. After this, @x2, @y2 will be the new current point. Note: Two points and their tangents do not determine a unique ellipse, so GSK just picks one. If you need more precise control, use [method@Gsk.PathBuilder.conic_to] or [method@Gsk.PathBuilder.svg_arc_to].
@px1 is x coordinate of first control point.
@py1 is y coordinate of first control point.
@px2 is x coordinate of second control point.
@py2 is y coordinate of second control point.
@rNone.
close ()
Ends the current contour with a line back to the start point. Note that this is different from calling [method@Gsk.PathBuilder.line_to] with the start point in that the contour will be closed. A closed contour behaves differently from an open one. When stroking, its start and end point are considered connected, so they will be joined via the line join, and not ended with line caps.
Adds a conic curve from the current point to @x2, @y2 with the given @weight and @x1, @y1 as the control point. The weight determines how strongly the curve is pulled towards the control point. A conic with weight 1 is identical to a quadratic Bézier curve with the same points. Conic curves can be used to draw ellipses and circles. They are also known as rational quadratic Bézier curves. After this, @x2, @y2 will be the new current point.
@px1 is x coordinate of control point.
@py1 is y coordinate of control point.
@px2 is x coordinate of the end of the curve.
@py2 is y coordinate of the end of the curve.
@pweight is weight of the control point, must be greater than zero.
Adds a cubic Bézier curve from the current point to @x3, @y3 with @x1, @y1 and @x2, @y2 as the control points. After this, @x3, @y3 will be the new current point.
@px1 is x coordinate of first control point.
@py1 is y coordinate of first control point.
@px2 is x coordinate of second control point.
@py2 is y coordinate of second control point.
@px3 is x coordinate of the end of the curve.
@py3 is y coordinate of the end of the curve.
@rNone.
free_to_path ()
Creates a new path from the current state of the builder, and unrefs the builder.
@rthe newly created path with all the contours added to the builder.
get_current_point ()
Gets the current point. The current point is used for relative drawing commands and updated after every operation. When the builder is created, the default current point is set to 0, 0. Note that this is different from cairo, which starts out without a current point.
Implements arc-to according to the HTML Canvas spec. A convenience function that implements the HTML arc_to functionality. After this, the current point will be the point where the circle with the given radius touches the line from @x1, @y1 to @x2, @y2.
@px1 is x coordinate of first control point.
@py1 is y coordinate of first control point.
@px2 is x coordinate of second control point.
@py2 is y coordinate of second control point.
@pradius is radius of the circle.
@rNone.
line_to (double x, double y)
Draws a line from the current point to @x, @y and makes it the new current point.
@px is x coordinate.
@py is y coordinate.
@rNone.
move_to (double x, double y)
Starts a new contour by placing the pen at @x, @y. If this function is called twice in succession, the first call will result in a contour made up of a single point. The second call will start a new contour.
Adds a quadratic Bézier curve from the current point to @x2, @y2 with @x1, @y1 as the control point. After this, @x2,
@y2will be the new current point.
@px1 is x coordinate of control point.
@py1 is y coordinate of control point.
@px2 is x coordinate of the end of the curve.
@py2 is y coordinate of the end of the curve.
@rNone.
ref ()
Acquires a reference on the given builder. This function is intended primarily for language bindings. GskPathBuilder objects should not be kept around.
@rthe given path builder with its reference count increased.
Adds an elliptical arc from the current point to @x2, @y2 with @x1, @y1 determining the tangent directions. All coordinates are given relative to the current point. This is the relative version of [method@Gsk.PathBuilder.arc_to].
Adds a conic curve from the current point to @x2, @y2 with the given @weight and @x1, @y1 as the control point. All coordinates are given relative to the current point. This is the relative version of [method@Gsk.PathBuilder.conic_to].
@px1 is x offset of control point.
@py1 is y offset of control point.
@px2 is x offset of the end of the curve.
@py2 is y offset of the end of the curve.
@pweight is weight of the curve, must be greater than zero.
Adds a cubic Bézier curve from the current point to @x3, @y3 with @x1, @y1 and @x2, @y2 as the control points. All coordinates are given relative to the current point. This is the relative version of [method@Gsk.PathBuilder.cubic_to].
Implements arc-to according to the HTML Canvas spec. All coordinates are given relative to the current point. This is the relative version of [method@Gsk.PathBuilder.html_arc_to].
@px1 is x coordinate of first control point.
@py1 is y coordinate of first control point.
@px2 is x coordinate of second control point.
@py2 is y coordinate of second control point.
@pradius is radius of the circle.
@rNone.
rel_line_to (double x, double y)
Draws a line from the current point to a point offset from it by @x, @y and makes it the new current point. This is the relative version of [method@Gsk.PathBuilder.line_to].
@px is x offset.
@py is y offset.
@rNone.
rel_move_to (double x, double y)
Starts a new contour by placing the pen at @x, @y relative to the current point. This is the relative version of [method@Gsk.PathBuilder.move_to].
Adds a quadratic Bézier curve from the current point to @x2, @y2 with @x1, @y1 the control point. All coordinates are given relative to the current point. This is the relative version of [method@Gsk.PathBuilder.quad_to].
Implements arc-to according to the SVG spec. All coordinates are given relative to the current point. This is the relative version of [method@Gsk.PathBuilder.svg_arc_to].
@prx is x radius.
@pry is y radius.
@px_axis_rotation is the rotation of the ellipsis.
@plarge_arc is whether to add the large arc.
@ppositive_sweep is whether to sweep in the positive direction.
Implements arc-to according to the SVG spec. A convenience function that implements the SVG arc_to functionality. After this, @x, @y will be the new current point.
@prx is x radius.
@pry is y radius.
@px_axis_rotation is the rotation of the ellipsis.
@plarge_arc is whether to add the large arc.
@ppositive_sweep is whether to sweep in the positive direction.
@px is x coordinate of the endpoint.
@py is y coordinate of the endpoint.
@rNone.
to_path ()
Creates a new path from the given builder. The given GskPathBuilder is reset to the initial state once this function returns. Calling this function again on the same builder instance will therefore produce an empty path, not a copy of the same path. This function is intended primarily for language bindings. C code should use [method@Gsk.PathBuilder.free_to_path].
@rthe newly created path with all the contours added to the builder.