StrokePaintAnimationClock



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

Summary

Public companion functions

@FloatRange(from = 0.0, to = 1.0, toInclusive = false) Float
calculateBasePaintAnimationPhaseForNewStroke(
    clockStateMillis: Long,
    brushFamilyLoopDurationMillis: @IntRange(from = 0, to = 16777216) Long
)

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

Cmn
@FloatRange(from = 0.0, to = 1.0, toInclusive = false) Float
calculateCurrentAnimationPhaseForBrushPaint(
    clockStateMillis: Long,
    brushFamilyLoopDurationMillis: @IntRange(from = 0, to = 16777216) Long,
    brushPaintLoopDurationMillis: @IntRange(from = 0, to = 16777216) Long,
    strokeBasePaintAnimationPhase: @FloatRange(from = 0.0, to = 1.0, toInclusive = false) Float
)

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.

Cmn

Public companion properties

StrokePaintAnimationClock

An animation clock whose clock state never changes.

Cmn

Public functions

Long

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

Cmn

Public companion functions

calculateBasePaintAnimationPhaseForNewStroke

fun calculateBasePaintAnimationPhaseForNewStroke(
    clockStateMillis: Long,
    brushFamilyLoopDurationMillis: @IntRange(from = 0, to = 16777216) Long
): @FloatRange(from = 0.0, to = 1.0, toInclusive = false) Float

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

fun calculateCurrentAnimationPhaseForBrushPaint(
    clockStateMillis: Long,
    brushFamilyLoopDurationMillis: @IntRange(from = 0, to = 16777216) Long,
    brushPaintLoopDurationMillis: @IntRange(from = 0, to = 16777216) Long,
    strokeBasePaintAnimationPhase: @FloatRange(from = 0.0, to = 1.0, toInclusive = false) Float
): @FloatRange(from = 0.0, to = 1.0, toInclusive = false) Float

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.

Public companion properties

STOPPED_CLOCK

val STOPPED_CLOCK: StrokePaintAnimationClock

An animation clock whose clock state never changes.

Public functions

getClockStateMillis

@AnyThread
fun getClockStateMillis(): Long

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.