Package limn.animation
Class ColorTransition
java.lang.Object
limn.animation.ColorTransition
An animated
Color: the color counterpart to Transition. It
fades from the current color to a new target over a duration with an easing,
so a widget can transition a fill/stroke/tint from a→b like a CSS color
transition. Internally it drives a Transition for the 0→1 progress and
blends with Color.lerp(limn.graphics.Color, float), so it inherits the same guarantees: it drives
itself off the scene ticker only while moving, is UI-thread-confined, and
snaps straight to the target when the owner is detached/headless or the
animation is disabled.
private final ColorTransition fill =
new ColorTransition(this, Theme.current().primary)
.duration(Theme.current().animHover).easing(Theme.current().animEasing);
// on state change:
fill.to(hovered ? Theme.current().primaryHover : Theme.current().primary);
// in onPaint:
canvas.fillRoundRect(x, y, w, h, r, fill.value());
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionduration(double seconds) Duration of one run, in seconds.The curve the interpolation follows.enabled(boolean value) Turns animation off, so a new target takes effect on the next frame.booleanWhether the colour is still moving towards its target.sceneTime(boolean value) voidJumps tocolorimmediately, cancelling any animation.target()voidAnimates from the currently-shown color totarget(snaps when detached/disabled).value()
-
Constructor Details
-
ColorTransition
Rests atinitial.
-
-
Method Details
-
duration
Duration of one run, in seconds. -
easing
The curve the interpolation follows. -
enabled
Turns animation off, so a new target takes effect on the next frame. -
sceneTime
SeeTransition.sceneTime(boolean). Off by default, like the transition it drives. -
to
Animates from the currently-shown color totarget(snaps when detached/disabled). -
snap
Jumps tocolorimmediately, cancelling any animation. -
value
- Returns:
- the current interpolated color; read this each paint
-
target
- Returns:
- the color it is heading toward
-
isAnimating
public boolean isAnimating()Whether the colour is still moving towards its target.
-