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

OffsetKt

public final class OffsetKt


Summary

Public methods

static final @NonNull Offset
Offset(float x, float y)

Constructs an Offset from the given relative x and y offsets

static final boolean
isFinite(@NonNull Offset receiver)

True if both x and y values of the Offset are finite

static final boolean

false when this is Offset.Unspecified.

static final boolean

true when this is Offset.Unspecified.

static final @NonNull Offset
lerp(@NonNull Offset start, @NonNull Offset stop, float fraction)

Linearly interpolate between two offsets.

static final @NonNull Offset
takeOrElse(
    @NonNull Offset receiver,
    @NonNull Function0<@NonNull Offset> block
)

If this Offset isSpecified then this is returned, otherwise block is executed and its result is returned.

Public methods

Offset

public static final @NonNull Offset Offset(float x, float y)

Constructs an Offset from the given relative x and y offsets

isFinite

public static final boolean isFinite(@NonNull Offset receiver)

True if both x and y values of the Offset are finite

isSpecified

public static final boolean isSpecified(@NonNull Offset receiver)

false when this is Offset.Unspecified.

isUnspecified

public static final boolean isUnspecified(@NonNull Offset receiver)

true when this is Offset.Unspecified.

lerp

public static final @NonNull Offset lerp(@NonNull Offset start, @NonNull Offset stop, float fraction)

Linearly interpolate between two offsets.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an AnimationController.

takeOrElse

public static final @NonNull Offset takeOrElse(
    @NonNull Offset receiver,
    @NonNull Function0<@NonNull Offset> block
)

If this Offset isSpecified then this is returned, otherwise block is executed and its result is returned.