KeyFrames

class KeyFrames<T : Drawable>(self: T, animation: Animation) : ComponentOp.Animatable<T>

KeyFrames

Keyframes are an easy way to create animations on components. PolyUI uses a Kotlin DSL to create them in an easy and concise way.

They can be created wherever a Drawable is in scope, so everything from events for mouse clicks; to in your initialization block; using the extension function keyframed.

Each keyframe can be added using a number between 0 (representing the start or 0%) to 100, representing the end or 100%. Each keyframe can control the color, rotation, position, skew and size of the component (using this function). They support different animation curves and durations using the animation parameter.

The syntax is as follows:

keyframed(2.seconds, Animations.Default) {
20 { // at 20% or 0.4 seconds, the rotation will be 25 degrees
rotation = 25.0
}
32.5 { // at 32.5%, the rotation will be 35 degrees
rotation = 35.0
}
50 {
rotation = 180.0
}
100 { // when it is finished, we will be fully rotated (equal to 0 degrees)
rotation = 360.0
}
}

Parameters

animation

the animation curve to use for each keyframe movement

self

the component to apply to.

Constructors

Link copied to clipboard
constructor(self: T, animation: Animation)

Properties

Link copied to clipboard
var onFinish: T.() -> Unit?

Functions

Link copied to clipboard
fun add()
Link copied to clipboard
open override fun apply()

Apply the operation, this is called before the component is rendered.

Link copied to clipboard
fun at(percent: Float, frame: KeyFrame.() -> Unit)
Link copied to clipboard
fun begin()
Link copied to clipboard
open fun exclusive(): Boolean

If this is true, when this drawable operation is attempted to be added, if one is already present, instead of replacing it, it will be ignored.

Link copied to clipboard
@ApiStatus.Experimental
open fun finishNow()

finish this operation immediately.

Link copied to clipboard
fun frame(percent: Float, frame: KeyFrame.() -> Unit)
Link copied to clipboard
operator fun Number.invoke(frame: KeyFrame.() -> Unit)
Link copied to clipboard
open fun reset()
Link copied to clipboard
open fun reverse()
Link copied to clipboard
open override fun unapply(): Boolean

Unapply the operation. this is called after the component is rendered.

Link copied to clipboard
open fun verify(): Boolean

override this function to verify that this operation is valid, which is run before it is applied. (default: always true)