2.5 <GskPathBuilder>

Structure: <GskPathBuilder>

Constructs <GskPath> objects.

A path is constructed like this:

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 path-builder:add-circle or by adding from other paths like path-builder: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 path-builder: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 path-builder: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.

Procedures

Method: path-builder:add-circle self center radius
Method: add-circle self center 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.

self

Passed: a <GskPathBuilder>.

a path builder

center

Passed: a <GraphenePoint>.

the center of the circle

radius

Passed: a real number.

the radius of the circle

Method: path-builder:add-layout self layout
Method: add-layout self layout

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

self

Passed: a <GskPathBuilder>.

a path builder

layout

Passed: a <PangoLayout>.

the pango layout to add

Method: path-builder:add-path self path
Method: add-path self path

Appends all of path to the builder.

self

Passed: a <GskPathBuilder>.

a path builder

path

Passed: a <GskPath>.

the path to append

Method: path-builder:add-rect self rect
Method: add-rect self 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.

self

Passed: a <GskPathBuilder>.

a path builder

rect

Passed: a <GrapheneRect>.

the rectangle to create a path for

Method: path-builder:add-reverse-path self path
Method: add-reverse-path self path

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

self

Passed: a <GskPathBuilder>.

a path builder

path

Passed: a <GskPath>.

the path to append

Method: path-builder:add-rounded-rect self rect
Method: add-rounded-rect self rect

Adds a rounded rectangle as a new contour.

The path is going around the rectangle in clockwise direction.

self

Passed: a <GskPathBuilder>.

a path builder

rect

Passed: a <GskRoundedRect>.

the rounded rect

Method: path-builder:add-segment self path start end
Method: add-segment self path start 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 path-builder:add-path.

self

Passed: a <GskPathBuilder>.

a path builder

path

Passed: a <GskPath>.

the path to take the segment to

start

Passed: a <GskPathPoint>.

the point on path to start at

end

Passed: a <GskPathPoint>.

the point on path to end at

Method: path-builder:arc-to self x1 y1 x2 y2
Method: arc-to self x1 y1 x2 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 path-builder:conic-to or path-builder:svg-arc-to.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of first control point

y1

Passed: a real number.

y coordinate of first control point

x2

Passed: a real number.

x coordinate of second control point

y2

Passed: a real number.

y coordinate of second control point

Method: path-builder:close self
Method: close self

Ends the current contour with a line back to the start point.

Note that this is different from calling path-builder: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.

self

Passed: a <GskPathBuilder>.

a path builder

Method: path-builder:conic-to self x1 y1 x2 y2 weight
Method: conic-to self x1 y1 x2 y2 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.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of control point

y1

Passed: a real number.

y coordinate of control point

x2

Passed: a real number.

x coordinate of the end of the curve

y2

Passed: a real number.

y coordinate of the end of the curve

weight

Passed: a real number.

weight of the control point, must be greater than zero

Method: path-builder:cubic-to self x1 y1 x2 y2 x3 y3
Method: cubic-to self x1 y1 x2 y2 x3 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.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of first control point

y1

Passed: a real number.

y coordinate of first control point

x2

Passed: a real number.

x coordinate of second control point

y2

Passed: a real number.

y coordinate of second control point

x3

Passed: a real number.

x coordinate of the end of the curve

y3

Passed: a real number.

y coordinate of the end of the curve

Method: path-builder:get-current-point self ⇒ %return
Method: get-current-point self ⇒ %return

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.

self

Passed: a <GskPathBuilder>.

a path builder

%return

Returned: a <GraphenePoint>.

the current point

Method: path-builder:html-arc-to self x1 y1 x2 y2 radius
Method: html-arc-to self x1 y1 x2 y2 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.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of first control point

y1

Passed: a real number.

y coordinate of first control point

x2

Passed: a real number.

x coordinate of second control point

y2

Passed: a real number.

y coordinate of second control point

radius

Passed: a real number.

radius of the circle

Method: path-builder:line-to self x y
Method: line-to self x y

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

self

Passed: a <GskPathBuilder>.

a path builder

x

Passed: a real number.

x coordinate

y

Passed: a real number.

y coordinate

Method: path-builder:move-to self x y
Method: move-to self x 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.

self

Passed: a <GskPathBuilder>.

a path builder

x

Passed: a real number.

x coordinate

y

Passed: a real number.

y coordinate

Procedure: path-builder:new ⇒ %return

Create a new <GskPathBuilder> object.

The resulting builder would create an empty <GskPath>. Use addition functions to add types to it.

%return

Returned: a <GskPathBuilder>.

a new <GskPathBuilder>

Method: path-builder:quad-to self x1 y1 x2 y2
Method: quad-to self x1 y1 x2 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.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of control point

y1

Passed: a real number.

y coordinate of control point

x2

Passed: a real number.

x coordinate of the end of the curve

y2

Passed: a real number.

y coordinate of the end of the curve

Method: path-builder:ref self ⇒ %return
Method: ref self ⇒ %return

Acquires a reference on the given builder.

This function is intended primarily for language bindings. <GskPathBuilder> objects should not be kept around.

self

Passed: a <GskPathBuilder>.

a path builder

%return

Returned: a <GskPathBuilder>.

the given path builder with its reference count increased

Method: path-builder:rel-arc-to self x1 y1 x2 y2
Method: rel-arc-to self x1 y1 x2 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 path-builder:arc-to.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of first control point

y1

Passed: a real number.

y coordinate of first control point

x2

Passed: a real number.

x coordinate of second control point

y2

Passed: a real number.

y coordinate of second control point

Method: path-builder:rel-conic-to self x1 y1 x2 y2 weight
Method: rel-conic-to self x1 y1 x2 y2 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 path-builder:conic-to.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x offset of control point

y1

Passed: a real number.

y offset of control point

x2

Passed: a real number.

x offset of the end of the curve

y2

Passed: a real number.

y offset of the end of the curve

weight

Passed: a real number.

weight of the curve, must be greater than zero

Method: path-builder:rel-cubic-to self x1 y1 x2 y2 x3 y3
Method: rel-cubic-to self x1 y1 x2 y2 x3 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 path-builder:cubic-to.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x offset of first control point

y1

Passed: a real number.

y offset of first control point

x2

Passed: a real number.

x offset of second control point

y2

Passed: a real number.

y offset of second control point

x3

Passed: a real number.

x offset of the end of the curve

y3

Passed: a real number.

y offset of the end of the curve

Method: path-builder:rel-html-arc-to self x1 y1 x2 y2 radius
Method: rel-html-arc-to self x1 y1 x2 y2 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 path-builder:html-arc-to.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x coordinate of first control point

y1

Passed: a real number.

y coordinate of first control point

x2

Passed: a real number.

x coordinate of second control point

y2

Passed: a real number.

y coordinate of second control point

radius

Passed: a real number.

radius of the circle

Method: path-builder:rel-line-to self x y
Method: rel-line-to self x 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 path-builder:line-to.

self

Passed: a <GskPathBuilder>.

a path builder

x

Passed: a real number.

x offset

y

Passed: a real number.

y offset

Method: path-builder:rel-move-to self x y
Method: rel-move-to self x y

Starts a new contour by placing the pen at x, y relative to the current point.

This is the relative version of path-builder:move-to.

self

Passed: a <GskPathBuilder>.

a path builder

x

Passed: a real number.

x offset

y

Passed: a real number.

y offset

Method: path-builder:rel-quad-to self x1 y1 x2 y2
Method: rel-quad-to self x1 y1 x2 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 path-builder:quad-to.

self

Passed: a <GskPathBuilder>.

a path builder

x1

Passed: a real number.

x offset of control point

y1

Passed: a real number.

y offset of control point

x2

Passed: a real number.

x offset of the end of the curve

y2

Passed: a real number.

y offset of the end of the curve

Method: path-builder:rel-svg-arc-to self rx ry x-axis-rotation large-arc positive-sweep x y
Method: rel-svg-arc-to self rx ry x-axis-rotation large-arc positive-sweep x y

Implements arc-to according to the SVG spec.

All coordinates are given relative to the current point.

This is the relative version of path-builder:svg-arc-to.

self

Passed: a <GskPathBuilder>.

a path builder

rx

Passed: a real number.

x radius

ry

Passed: a real number.

y radius

x-axis-rotation

Passed: a real number.

the rotation of the ellipsis

large-arc

Passed: a boolean.

whether to add the large arc

positive-sweep

Passed: a boolean.

whether to sweep in the positive direction

x

Passed: a real number.

x coordinate of the endpoint

y

Passed: a real number.

y coordinate of the endpoint

Method: path-builder:svg-arc-to self rx ry x-axis-rotation large-arc positive-sweep x y
Method: svg-arc-to self rx ry x-axis-rotation large-arc positive-sweep x 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.

self

Passed: a <GskPathBuilder>.

a path builder

rx

Passed: a real number.

x radius

ry

Passed: a real number.

y radius

x-axis-rotation

Passed: a real number.

the rotation of the ellipsis

large-arc

Passed: a boolean.

whether to add the large arc

positive-sweep

Passed: a boolean.

whether to sweep in the positive direction

x

Passed: a real number.

x coordinate of the endpoint

y

Passed: a real number.

y coordinate of the endpoint

Method: path-builder:to-path self ⇒ %return
Method: to-path self ⇒ %return

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 Gsk.PathBuilder.free_to_path.

self

Passed: a <GskPathBuilder>.

a path builder

%return

Returned: a <GskPath>.

the newly created path with all the contours added to the builder

Method: path-builder:unref self
Method: unref self

Releases a reference on the given builder.

self

Passed: a <GskPathBuilder>.

a path builder