PathPoint
Added in version 4.14.
- class PathPoint(*args, **kwargs)
GskPathPoint
is an opaque type representing a point on a path.
It can be queried for properties of the path at that point, such as its tangent or its curvature.
To obtain a GskPathPoint
, use get_closest_point
,
get_start_point
, get_end_point
or get_point
.
Note that GskPathPoint
structs are meant to be stack-allocated,
and don’t hold a reference to the path object they are obtained from.
It is the callers responsibility to keep a reference to the path
as long as the GskPathPoint
is used.
Methods
- class PathPoint
- compare(point2: PathPoint) int
Returns whether
point1
is before or afterpoint2
.Added in version 4.14.
- Parameters:
point2 – another
GskPathPoint
- equal(point2: PathPoint) bool
Returns whether the two path points refer to the same location on all paths.
Note that the start- and endpoint of a closed contour will compare nonequal according to this definition. Use
is_closed
to find out if the start- and endpoint of a concrete path refer to the same location.Added in version 4.14.
- Parameters:
point2 – another
GskPathPoint
- get_curvature(path: Path, direction: PathDirection) tuple[float, Point]
Calculates the curvature of the path at the point.
Optionally, returns the center of the osculating circle as well. The curvature is the inverse of the radius of the osculating circle.
Lines have a curvature of zero (indicating an osculating circle of infinite radius. In this case, the
center
is not modified.Circles with a radius of zero have
INFINITY
as curvatureNote that certain points on a path may not have a single curvature, such as sharp turns. At such points, there are two curvatures – the (limit of) the curvature of the path going into the point, and the (limit of) the curvature of the path coming out of it. The
direction
argument lets you choose which one to get.Added in version 4.14.
- Parameters:
path – the path that
point
is ondirection – the direction for which to return the curvature
- get_distance(measure: PathMeasure) float
Returns the distance from the beginning of the path to
point
.Added in version 4.14.
- Parameters:
measure – a
GskPathMeasure
for the path
- get_position(path: Path) Point
Gets the position of the point.
Added in version 4.14.
- Parameters:
path – the path that
point
is on
- get_rotation(path: Path, direction: PathDirection) float
Gets the direction of the tangent at a given point.
This is a convenience variant of
get_tangent
that returns the angle between the tangent and the X axis. The angle can e.g. be used in gtk_snapshot_rotate().Added in version 4.14.
- Parameters:
path – the path that
point
is ondirection – the direction for which to return the rotation
- get_tangent(path: Path, direction: PathDirection) Vec2
Gets the tangent of the path at the point.
Note that certain points on a path may not have a single tangent, such as sharp turns. At such points, there are two tangents – the direction of the path going into the point, and the direction coming out of it. The
direction
argument lets you choose which one to get.If the path is just a single point (e.g. a circle with radius zero), then
tangent
is set to0, 0
.If you want to orient something in the direction of the path,
get_rotation
may be more convenient to use.Added in version 4.14.
- Parameters:
path – the path that
point
is ondirection – the direction for which to return the tangent