Package ch.bailu.gtk.gsk
Klasse PathBuilder
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.gsk.PathBuilder
- Alle implementierten Schnittstellen:
PointerInterface
Constructs `GskPath` objects.
A path is constructed like this:
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.
A path is constructed like this:
<!-- language="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.
-
Feldübersicht
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungCreate a new `GskPathBuilder` object.PathBuilder
(PointerContainer pointer) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
addCairoPath
(Path path) Adds a Cairo path to the builder.void
Adds a circle as a new contour.void
Adds the outlines for the glyphs in @layout to the builder.void
Appends all of @path to the builder.void
Adds a rectangle as a new contour.void
addReversePath
(Path path) Appends all of @path to the builder, in reverse order.void
addRoundedRect
(RoundedRect rect) Adds a rounded rectangle as a new contour.void
addSegment
(Path path, PathPoint start, PathPoint end) Adds a segment of a path to the builder.void
arcTo
(float x1, float y1, float x2, float y2) Adds an elliptical arc from the current point to @x2, @y2
with @x1, @y1 determining the tangent directions.void
close()
Ends the current contour with a line back to the start point.void
conicTo
(float x1, float y1, float x2, float y2, float weight) Adds a [conic curve](https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline)
from the current point to @x2, @y2 with the given @weight and @x1, @y1 as the
control point.void
cubicTo
(float x1, float y1, float x2, float y2, float x3, float y3) Adds a [cubic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x3, @y3 with @x1, @y1 and @x2, @y2 as the control
points.Creates a new path from the current state of the
builder, and unrefs the builder.static ClassHandler
Gets the current point.static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
void
htmlArcTo
(float x1, float y1, float x2, float y2, float radius) Implements arc-to according to the HTML Canvas spec.void
lineTo
(float x, float y) Draws a line from the current point to @x, @y and makes it
the new current point.void
moveTo
(float x, float y) Starts a new contour by placing the pen at @x, @y.void
quadTo
(float x1, float y1, float x2, float y2) Adds a [quadratic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x2, @y2 with @x1, @y1 as the control point.ref()
Acquires a reference on the given builder.void
relArcTo
(float x1, float y1, float x2, float y2) Adds an elliptical arc from the current point to @x2, @y2
with @x1, @y1 determining the tangent directions.void
relConicTo
(float x1, float y1, float x2, float y2, float weight) Adds a [conic curve](https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline)
from the current point to @x2, @y2 with the given @weight and @x1, @y1 as the
control point.void
relCubicTo
(float x1, float y1, float x2, float y2, float x3, float y3) Adds a [cubic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x3, @y3 with @x1, @y1 and @x2, @y2 as the control
points.void
relHtmlArcTo
(float x1, float y1, float x2, float y2, float radius) Implements arc-to according to the HTML Canvas spec.void
relLineTo
(float x, float y) Draws a line from the current point to a point offset from it
by @x, @y and makes it the new current point.void
relMoveTo
(float x, float y) Starts a new contour by placing the pen at @x, @y
relative to the current point.void
relQuadTo
(float x1, float y1, float x2, float y2) Adds a [quadratic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x2, @y2 with @x1, @y1 the control point.void
relSvgArcTo
(float rx, float ry, float x_axis_rotation, boolean large_arc, boolean positive_sweep, float x, float y) Implements arc-to according to the SVG spec.void
svgArcTo
(float rx, float ry, float x_axis_rotation, boolean large_arc, boolean positive_sweep, float x, float y) Implements arc-to according to the SVG spec.toPath()
Creates a new path from the given builder.void
unref()
Releases a reference on the given builder.Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Konstruktordetails
-
PathBuilder
-
PathBuilder
public PathBuilder()Create a new `GskPathBuilder` object.
The resulting builder would create an empty `GskPath`.
Use addition functions to add types to it.
-
-
Methodendetails
-
getClassHandler
-
addCairoPath
Adds a Cairo path to the builder.
You can use cairo_copy_path() to access the path
from a Cairo context.- Parameter:
path
- a path
-
addCircle
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.- Parameter:
center
- the center of the circleradius
- the radius of the circle
-
addLayout
Adds the outlines for the glyphs in @layout to the builder.- Parameter:
layout
- the pango layout to add
-
addPath
Appends all of @path to the builder.- Parameter:
path
- the path to append
-
addRect
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.- Parameter:
rect
- the rectangle to create a path for
-
addReversePath
Appends all of @path to the builder, in reverse order.- Parameter:
path
- the path to append
-
addRoundedRect
Adds a rounded rectangle as a new contour.
The path is going around the rectangle in clockwise direction.- Parameter:
rect
- the rounded rect
-
addSegment
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].- Parameter:
path
- the path to take the segment tostart
- the point on @path to start atend
- the point on @path to end at
-
arcTo
public void arcTo(float x1, float y1, float x2, float 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].
<picture>
<source srcset="arc-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Arc To" src="arc-light.png">
</picture>- Parameter:
x1
- x coordinate of first control pointy1
- y coordinate of first control pointx2
- x coordinate of second control pointy2
- y coordinate of second control point
-
close
public void 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. -
conicTo
public void conicTo(float x1, float y1, float x2, float y2, float weight) Adds a [conic curve](https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline)
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.
<picture>
<source srcset="conic-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Conic To" src="conic-light.png">
</picture>- Parameter:
x1
- x coordinate of control pointy1
- y coordinate of control pointx2
- x coordinate of the end of the curvey2
- y coordinate of the end of the curveweight
- weight of the control point, must be greater than zero
-
cubicTo
public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) Adds a [cubic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_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.
<picture>
<source srcset="cubic-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Cubic To" src="cubic-light.png">
</picture>- Parameter:
x1
- x coordinate of first control pointy1
- y coordinate of first control pointx2
- x coordinate of second control pointy2
- y coordinate of second control pointx3
- x coordinate of the end of the curvey3
- y coordinate of the end of the curve
-
freeToPath
Creates a new path from the current state of the
builder, and unrefs the builder.- Gibt zurück:
- the newly created path with all the contours added to the builder
-
getCurrentPoint
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.- Gibt zurück:
- the current point
-
htmlArcTo
public void htmlArcTo(float x1, float y1, float x2, float y2, float radius) Implements arc-to according to the HTML Canvas spec.
A convenience function that implements the
[HTML arc_to](https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arcto-dev)
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.- Parameter:
x1
- x coordinate of first control pointy1
- y coordinate of first control pointx2
- x coordinate of second control pointy2
- y coordinate of second control pointradius
- radius of the circle
-
lineTo
public void lineTo(float x, float y) Draws a line from the current point to @x, @y and makes it
the new current point.
<picture>
<source srcset="line-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Line To" src="line-light.png">
</picture>- Parameter:
x
- x coordinatey
- y coordinate
-
moveTo
public void moveTo(float x, float 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.- Parameter:
x
- x coordinatey
- y coordinate
-
quadTo
public void quadTo(float x1, float y1, float x2, float y2) Adds a [quadratic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_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.
<picture>
<source srcset="quad-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Quad To" src="quad-light.png">
</picture>- Parameter:
x1
- x coordinate of control pointy1
- y coordinate of control pointx2
- x coordinate of the end of the curvey2
- y coordinate of the end of the curve
-
ref
Acquires a reference on the given builder.
This function is intended primarily for language bindings.
`GskPathBuilder` objects should not be kept around.- Gibt zurück:
- the given path builder with its reference count increased
-
relArcTo
public void relArcTo(float x1, float y1, float x2, float 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].- Parameter:
x1
- x coordinate of first control pointy1
- y coordinate of first control pointx2
- x coordinate of second control pointy2
- y coordinate of second control point
-
relConicTo
public void relConicTo(float x1, float y1, float x2, float y2, float weight) Adds a [conic curve](https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline)
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].- Parameter:
x1
- x offset of control pointy1
- y offset of control pointx2
- x offset of the end of the curvey2
- y offset of the end of the curveweight
- weight of the curve, must be greater than zero
-
relCubicTo
public void relCubicTo(float x1, float y1, float x2, float y2, float x3, float y3) Adds a [cubic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_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].- Parameter:
x1
- x offset of first control pointy1
- y offset of first control pointx2
- x offset of second control pointy2
- y offset of second control pointx3
- x offset of the end of the curvey3
- y offset of the end of the curve
-
relHtmlArcTo
public void relHtmlArcTo(float x1, float y1, float x2, float y2, float 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].- Parameter:
x1
- x coordinate of first control pointy1
- y coordinate of first control pointx2
- x coordinate of second control pointy2
- y coordinate of second control pointradius
- radius of the circle
-
relLineTo
public void relLineTo(float x, float 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].- Parameter:
x
- x offsety
- y offset
-
relMoveTo
public void relMoveTo(float x, float 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].- Parameter:
x
- x offsety
- y offset
-
relQuadTo
public void relQuadTo(float x1, float y1, float x2, float y2) Adds a [quadratic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_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].- Parameter:
x1
- x offset of control pointy1
- y offset of control pointx2
- x offset of the end of the curvey2
- y offset of the end of the curve
-
relSvgArcTo
public void relSvgArcTo(float rx, float ry, float x_axis_rotation, boolean large_arc, boolean positive_sweep, float x, float 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].- Parameter:
rx
- x radiusry
- y radiusx_axis_rotation
- the rotation of the ellipsislarge_arc
- whether to add the large arcpositive_sweep
- whether to sweep in the positive directionx
- x coordinate of the endpointy
- y coordinate of the endpoint
-
svgArcTo
public void svgArcTo(float rx, float ry, float x_axis_rotation, boolean large_arc, boolean positive_sweep, float x, float y) Implements arc-to according to the SVG spec.
A convenience function that implements the
[SVG arc_to](https://www.w3.org/TR/SVG11/paths.html#PathDataEllipticalArcCommands)
functionality.
After this, @x, @y will be the new current point.- Parameter:
rx
- x radiusry
- y radiusx_axis_rotation
- the rotation of the ellipsislarge_arc
- whether to add the large arcpositive_sweep
- whether to sweep in the positive directionx
- x coordinate of the endpointy
- y coordinate of the endpoint
-
toPath
Creates a new path from the given builder.
The given `GskPathBuilder` is reset once this function returns;
you cannot call this function multiple times on the same builder
instance.
This function is intended primarily for language bindings.
C code should use [method@Gsk.PathBuilder.free_to_path].- Gibt zurück:
- the newly created path with all the contours added to the builder
-
unref
public void unref()Releases a reference on the given builder. -
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-