Package limn.animation
Class Motion
java.lang.Object
limn.animation.Motion
How long the toolkit's motion takes, given what the user asked the system for. While
SystemPreferences.reduceMotion() is set, motion finishes at once: a Transition
jumps to its target, and popups, menus and dialogs open and close without fading, as native
toolkits do for a user who asked every application for less motion.
An animation that drives its own clock reads this too. One whose motion carries information,
such as a progress sweep or a busy spinner, keeps moving but steps: it moves a few
times a second instead of every frame.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleHow often a stepped animation moves, in seconds: four times a second. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleduration(double seconds) static doubleprogress(double dt, double seconds) The share of a fade that one frame advances:dt / seconds, or all of it when the fade takes no time or motion is reduced.static booleanreduced()static doublestepped(double dt, double held) Holds a stepped animation's time between steps: add each frame's length toheld; the animation moves only when this answers more than zero, by the time it answers, while motion is reduced.
-
Field Details
-
STEP_SECONDS
public static final double STEP_SECONDSHow often a stepped animation moves, in seconds: four times a second.- See Also:
-
-
Method Details
-
reduced
public static boolean reduced()- Returns:
- whether the user asked for less motion. Any thread
-
duration
public static double duration(double seconds) - Parameters:
seconds- how long the motion takes when nothing is reduced- Returns:
seconds, or0while motion is reduced. Any thread
-
progress
public static double progress(double dt, double seconds) The share of a fade that one frame advances:dt / seconds, or all of it when the fade takes no time or motion is reduced. Never NaN, even for a frame of zero length.- Parameters:
dt- the frame's length, in secondsseconds- how long the whole fade takes when nothing is reduced- Returns:
- the share to add,
1or more for a fade that ends now
-
stepped
public static double stepped(double dt, double held) Holds a stepped animation's time between steps: add each frame's length toheld; the animation moves only when this answers more than zero, by the time it answers, while motion is reduced. Otherwise every frame moves by its own length.double moved = Motion.stepped(dt, held); held = moved > 0 ? 0 : held + dt; if (moved > 0) { phase += moved / period; invalidate(); }- Parameters:
dt- this frame's length, in secondsheld- the time held since the last step, in seconds- Returns:
- the time to move by now, or
0to hold this frame
-