StrokePaintAnimationClock


public fun interface StrokePaintAnimationClock


Controls animated paint textures for rendered strokes. Typically a single StrokePaintAnimationClock object is used for all strokes in a document.

Summary

Public fields

default static final @NonNull StrokePaintAnimationClock

An animation clock whose clock state never changes.

Public methods

default static final @FloatRange(from = 0.0, to = 1.0, toInclusive = false) float
calculateBasePaintAnimationPhaseForNewStroke(
    long clockStateMillis,
    @IntRange(from = 0, to = 16777216) long brushFamilyLoopDurationMillis
)

Given a whole-stroke animation duration, calculates the [0, 1) base paint animation phase value for the stroke.

default static final @FloatRange(from = 0.0, to = 1.0, toInclusive = false) float
calculateCurrentAnimationPhaseForBrushPaint(
    long clockStateMillis,
    @IntRange(from = 0, to = 16777216) long brushFamilyLoopDurationMillis,
    @IntRange(from = 0, to = 16777216) long brushPaintLoopDurationMillis,
    @FloatRange(from = 0.0, to = 1.0, toInclusive = false) float strokeBasePaintAnimationPhase
)

Given a stroke's base paint animation phase, and its BrushFamily's paint animation loop duration, and the paint animation loop duration for a particular BrushPaint in that family, returns the [0, 1) phase value that BrushPaint should have at the given clock state.

abstract long

Returns the number of subjective milliseconds that have elapsed since this clock's zero state.

Public fields

STOPPED_CLOCK

default static final @NonNull StrokePaintAnimationClock STOPPED_CLOCK

An animation clock whose clock state never changes.

Public methods

calculateBasePaintAnimationPhaseForNewStroke

Added in 1.1.0-alpha11
default static final @FloatRange(from = 0.0, to = 1.0, toInclusive = false) float calculateBasePaintAnimationPhaseForNewStroke(
    long clockStateMillis,
    @IntRange(from = 0, to = 16777216) long brushFamilyLoopDurationMillis
)

Given a whole-stroke animation duration, calculates the [0, 1) base paint animation phase value for the stroke. This is the paint animation progress value that the stroke would use if the paint animation clock state were zero, such that the stroke is at the start of its animation at the current clock state.

If brushFamilyLoopDurationMillis is zero, indicating that the stroke's BrushFamily contains no animated BrushPaints, then this method returns zero.

calculateCurrentAnimationPhaseForBrushPaint

Added in 1.1.0-alpha11
default static final @FloatRange(from = 0.0, to = 1.0, toInclusive = false) float calculateCurrentAnimationPhaseForBrushPaint(
    long clockStateMillis,
    @IntRange(from = 0, to = 16777216) long brushFamilyLoopDurationMillis,
    @IntRange(from = 0, to = 16777216) long brushPaintLoopDurationMillis,
    @FloatRange(from = 0.0, to = 1.0, toInclusive = false) float strokeBasePaintAnimationPhase
)

Given a stroke's base paint animation phase, and its BrushFamily's paint animation loop duration, and the paint animation loop duration for a particular BrushPaint in that family, returns the [0, 1) phase value that BrushPaint should have at the given clock state.

If brushPaintLoopDurationMillis is zero, indicating that the BrushPaint is not animated, then this method returns zero. Otherwise, brushFamilyLoopDurationMillis must be a multiple of brushPaintLoopDurationMillis.

getClockStateMillis

Added in 1.1.0-alpha11
@AnyThread
abstract long getClockStateMillis()

Returns the number of subjective milliseconds that have elapsed since this clock's zero state. Depending on the implementation, this value may update only once per frame, and it may change at a different speed than real time.

This method must be safe to call from any thread.