{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PathMeasure

public interface PathMeasure

Known direct subclasses

Summary

Public methods

abstract float

The total length of the current contour, or 0 if no path is associated with this measure object.

abstract @NonNull Offset
getPosition(float distance)

Pins distance to 0 <= distance <= getLength(), and then computes the corresponding position

abstract boolean
getSegment(
    float startDistance,
    float stopDistance,
    @NonNull Path destination,
    boolean startWithMoveTo
)

Given a start and stop distance, return in dst the intervening segment(s).

abstract @NonNull Offset
getTangent(float distance)

Pins distance to 0 <= distance <= getLength(), and then computes the corresponding tangent

abstract void
setPath(Path path, boolean forceClosed)

Assign a new path, or null to have none.

Public methods

getLength

abstract float getLength()

The total length of the current contour, or 0 if no path is associated with this measure object.

getPosition

abstract @NonNull Offset getPosition(float distance)

Pins distance to 0 <= distance <= getLength(), and then computes the corresponding position

Parameters
float distance

The distance along the current contour to sample

Returns
@NonNull Offset

Offset.Unspecified if there is no path set

getSegment

abstract boolean getSegment(
    float startDistance,
    float stopDistance,
    @NonNull Path destination,
    boolean startWithMoveTo
)

Given a start and stop distance, return in dst the intervening segment(s). If the segment is zero-length, return false, else return true. startD and stopD are pinned to legal values (0..getLength()). If startD >= stopD then return false (and leave dst untouched). Begin the segment with a moveTo if startWithMoveTo is true.

getTangent

abstract @NonNull Offset getTangent(float distance)

Pins distance to 0 <= distance <= getLength(), and then computes the corresponding tangent

Parameters
float distance

The distance along the current contour to sample

Returns
@NonNull Offset

Offset.Unspecified if there is no path set

setPath

abstract void setPath(Path path, boolean forceClosed)

Assign a new path, or null to have none.