Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GskPathBuilder

[30:7] extends: object

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.

    • @p Handle 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.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A 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.

    • @p path is a path.
    • @r None.
  • 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.

    • @p center is the center of the circle.
    • @p radius is the radius of the circle.
    • @r None.
  • add_layout (object layout)

    Adds the outlines for the glyphs in @layout to the builder.

    • @p layout is the pango layout to add.
    • @r None.
  • add_path (object path)

    Appends all of @path to the builder.

    • @p path is the path to append.
    • @r None.
  • 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.

    • @p rect is the rectangle to create a path for.
    • @r None.
  • add_reverse_path (object path)

    Appends all of @path to the builder, in reverse order.

    • @p path is the path to append.
    • @r None.
  • add_rounded_rect (object rect)

    Adds a rounded rectangle as a new contour. The path is going around the rectangle in clockwise direction.

    • @p rect is the rounded rect.
    • @r None.
  • add_segment (object path, object start, object end)

    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].
    • @p path is the path to take the segment to.
    • @p start is the point on @path to start at.
    • @p end is the point on @path to end at.
    • @r None.
  • arc_to (double x1, double y1, double x2, double y2)

    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]. Arc To

    • @p x1 is x coordinate of first control point.
    • @p y1 is y coordinate of first control point.
    • @p x2 is x coordinate of second control point.
    • @p y2 is y coordinate of second control point.
    • @r None.
  • 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.

    • @r None.
  • conic_to (double x1, double y1, double x2, double y2, double weight)

    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. Conic To

    • @p x1 is x coordinate of control point.
    • @p y1 is y coordinate of control point.
    • @p x2 is x coordinate of the end of the curve.
    • @p y2 is y coordinate of the end of the curve.
    • @p weight is weight of the control point, must be greater than zero.
    • @r None.
  • cubic_to (double x1, double y1, double x2, double y2, double x3, double y3)

    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. Cubic To

    • @p x1 is x coordinate of first control point.
    • @p y1 is y coordinate of first control point.
    • @p x2 is x coordinate of second control point.
    • @p y2 is y coordinate of second control point.
    • @p x3 is x coordinate of the end of the curve.
    • @p y3 is y coordinate of the end of the curve.
    • @r None.
  • free_to_path ()

    Creates a new path from the current state of the builder, and unrefs the builder.

    • @r the 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.

    • @r the current point.
  • html_arc_to (double x1, double y1, double x2, double y2, double radius)

    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.

    • @p x1 is x coordinate of first control point.
    • @p y1 is y coordinate of first control point.
    • @p x2 is x coordinate of second control point.
    • @p y2 is y coordinate of second control point.
    • @p radius is radius of the circle.
    • @r None.
  • line_to (double x, double y)

    Draws a line from the current point to @x, @y and makes it the new current point. Line To

    • @p x is x coordinate.
    • @p y is y coordinate.
    • @r None.
  • 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.

    • @p x is x coordinate.
    • @p y is y coordinate.
    • @r None.
  • quad_to (double x1, double y1, double x2, double y2)

    Adds a quadratic Bézier curve from the current point to @x2, @y2 with @x1, @y1 as the control point. After this, @x2,

    • @y2 will be the new current point. Quad To
    • @p x1 is x coordinate of control point.
    • @p y1 is y coordinate of control point.
    • @p x2 is x coordinate of the end of the curve.
    • @p y2 is y coordinate of the end of the curve.
    • @r None.
  • ref ()

    Acquires a reference on the given builder. This function is intended primarily for language bindings. GskPathBuilder objects should not be kept around.

    • @r the given path builder with its reference count increased.
  • rel_arc_to (double x1, double y1, double x2, double y2)

    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].

    • @p x1 is x coordinate of first control point.
    • @p y1 is y coordinate of first control point.
    • @p x2 is x coordinate of second control point.
    • @p y2 is y coordinate of second control point.
    • @r None.
  • rel_conic_to (double x1, double y1, double x2, double y2, double weight)

    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].

    • @p x1 is x offset of control point.
    • @p y1 is y offset of control point.
    • @p x2 is x offset of the end of the curve.
    • @p y2 is y offset of the end of the curve.
    • @p weight is weight of the curve, must be greater than zero.
    • @r None.
  • rel_cubic_to (double x1, double y1, double x2, double y2, double x3, double y3)

    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].

    • @p x1 is x offset of first control point.
    • @p y1 is y offset of first control point.
    • @p x2 is x offset of second control point.
    • @p y2 is y offset of second control point.
    • @p x3 is x offset of the end of the curve.
    • @p y3 is y offset of the end of the curve.
    • @r None.
  • rel_html_arc_to (double x1, double y1, double x2, double y2, double radius)

    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].

    • @p x1 is x coordinate of first control point.
    • @p y1 is y coordinate of first control point.
    • @p x2 is x coordinate of second control point.
    • @p y2 is y coordinate of second control point.
    • @p radius is radius of the circle.
    • @r None.
  • 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].

    • @p x is x offset.
    • @p y is y offset.
    • @r None.
  • 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].

    • @p x is x offset.
    • @p y is y offset.
    • @r None.
  • rel_quad_to (double x1, double y1, double x2, double y2)

    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].

    • @p x1 is x offset of control point.
    • @p y1 is y offset of control point.
    • @p x2 is x offset of the end of the curve.
    • @p y2 is y offset of the end of the curve.
    • @r None.
  • rel_svg_arc_to (double rx, double ry, double x_axis_rotation, bool large_arc, bool positive_sweep, double x, double y)

    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].

    • @p rx is x radius.
    • @p ry is y radius.
    • @p x_axis_rotation is the rotation of the ellipsis.
    • @p large_arc is whether to add the large arc.
    • @p positive_sweep is whether to sweep in the positive direction.
    • @p x is x coordinate of the endpoint.
    • @p y is y coordinate of the endpoint.
    • @r None.
  • svg_arc_to (double rx, double ry, double x_axis_rotation, bool large_arc, bool positive_sweep, double x, double y)

    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.

    • @p rx is x radius.
    • @p ry is y radius.
    • @p x_axis_rotation is the rotation of the ellipsis.
    • @p large_arc is whether to add the large arc.
    • @p positive_sweep is whether to sweep in the positive direction.
    • @p x is x coordinate of the endpoint.
    • @p y is y coordinate of the endpoint.
    • @r None.
  • 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].

    • @r the newly created path with all the contours added to the builder.
  • unref ()

    Releases a reference on the given builder.

    • @r None.