Class PathMeasure

All Implemented Interfaces:
Proxy

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

Performs measurements on paths such as determining the length of the path.

Many measuring operations require sampling the path length at intermediate points. Therefore, a GskPathMeasure has a tolerance that determines what precision is required for such approximations.

A GskPathMeasure struct is a reference counted struct and should be treated as opaque.

Since:
4.14
  • Constructor Details

    • PathMeasure

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

      public PathMeasure(Path path)
      Creates a measure object for the given path with the default tolerance.
      Parameters:
      path - the path to measure
      Since:
      4.14
  • Method Details

    • getType

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

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

      public static PathMeasure withTolerance(Path path, float tolerance)
      Creates a measure object for the given path and tolerance.
      Parameters:
      path - the path to measure
      tolerance - the tolerance for measuring operations
      Returns:
      a new GskPathMeasure representing path
      Since:
      4.14
    • getLength

      public float getLength()

      Gets the length of the path being measured.

      The length is cached, so this function does not do any work.

      Returns:
      the length of the path measured by this PathMeasure
      Since:
      4.14
    • getPath

      public Path getPath()
      Returns the path that the measure was created for.
      Returns:
      the path of this PathMeasure
      Since:
      4.14
    • getPoint

      public boolean getPoint(float distance, PathPoint result)

      Gets the point at the given distance into the path.

      An empty path has no points, so false is returned in that case.

      Parameters:
      distance - the distance
      result - return location for the point
      Returns:
      true if result was set
      Since:
      4.14
    • getTolerance

      public float getTolerance()
      Returns the tolerance that the measure was created with.
      Returns:
      the tolerance of this PathMeasure
      Since:
      4.14
    • ref

      public PathMeasure ref()
      Increases the reference count of a GskPathMeasure by one.
      Returns:
      the passed in GskPathMeasure.
      Since:
      4.14
    • unref

      public void unref()

      Decreases the reference count of a GskPathMeasure by one.

      If the resulting reference count is zero, frees the object.

      Since:
      4.14