Class PathPoint

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class PathPoint extends ProxyInstance

Represents 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 Path.getClosestPoint(Point, float, PathPoint, Out), Path.getStartPoint(PathPoint), Path.getEndPoint(PathPoint) or PathMeasure.getPoint(float, PathPoint).

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.

Since:
4.14
  • Constructor Details

    • PathPoint

      public PathPoint(MemorySegment address)
      Create a PathPoint proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • PathPoint

      public PathPoint(Arena arena)
      Allocate a new PathPoint.
      Parameters:
      arena - to control the memory allocation scope
    • PathPoint

      public PathPoint()
      Allocate a new PathPoint. The memory is allocated with Arena.ofAuto().
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the PathPoint class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readAlignment

      public @Nullable Vec4 readAlignment()
      Read the value of the field alignment.
      Returns:
      The value of the field alignment
    • writeAlignment

      public void writeAlignment(@Nullable Vec4 alignment)
      Write a value in the field alignment.
      Parameters:
      alignment - The new value for the field alignment
    • compare

      public int compare(PathPoint point2)
      Returns whether this PathPoint is before or after point2.
      Parameters:
      point2 - another path point
      Returns:
      -1 if this PathPoint is before point2, 1 if this PathPoint is after point2, 0 if they are equal
      Since:
      4.14
    • copy

      public PathPoint copy()
      Copies a path point.
      Returns:
      the copied point
      Since:
      4.14
    • equal

      public boolean equal(PathPoint point2)

      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 Path.isClosed() to find out if the start- and endpoint of a concrete path refer to the same location.

      Parameters:
      point2 - another path point
      Returns:
      true if this PathPoint and point2 are equal
      Since:
      4.14
    • free

      public void free()
      Frees a path point copied by copy().
      Since:
      4.14
    • getCurvature

      public float getCurvature(Path path, PathDirection direction, @Nullable Point center)

      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 curvature

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

      Osculating circle
      Parameters:
      path - the path that this PathPoint is on
      direction - the direction for which to return the curvature
      center - return location for the center of the osculating circle
      Returns:
      the curvature of the path at the given point
      Since:
      4.14
    • getDistance

      public float getDistance(PathMeasure measure)
      Returns the distance from the beginning of the path to the point.
      Parameters:
      measure - a path measure for the path
      Returns:
      the distance of this PathPoint
      Since:
      4.14
    • getPosition

      public void getPosition(Path path, Point position)
      Gets the position of the point.
      Parameters:
      path - the path that this PathPoint is on
      position - Return location for the coordinates of the point
      Since:
      4.14
    • getRotation

      public float getRotation(Path path, PathDirection direction)

      Gets the direction of the tangent at a given point.

      This is a convenience variant of getTangent(Path, PathDirection, Vec2) that returns the angle between the tangent and the X axis. The angle can e.g. be used in gtk_snapshot_rotate().

      Parameters:
      path - the path that this PathPoint is on
      direction - the direction for which to return the rotation
      Returns:
      the angle between the tangent and the X axis, in degrees
      Since:
      4.14
    • getTangent

      public void getTangent(Path path, PathDirection direction, Vec2 tangent)

      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 the tangent is set to 0, 0.

      If you want to orient something in the direction of the path, getRotation(Path, PathDirection) may be more convenient to use.

      Parameters:
      path - the path that this PathPoint is on
      direction - the direction for which to return the tangent
      tangent - Return location for the tangent at the point
      Since:
      4.14