Java Reference
In-Depth Information
A common way to interpolate is to provide a mathematical function that repre-
sents a drawn curve between 0.0 and 1.0 for the time, and 0.0 and 1.0 for the value.
The output of this function represents the fractional change in the value between
the start value and the end value for the target variable. This pattern of interpola-
tion is quite common; to facilitate it, JavaFX provides the javafx.animation
.SimpleInterpolator abstract class. All the standard interpolators extend Simple-
Interpolator , and later in this chapter we will show an example of creating a
custom interpolator based on it.
Standard Interpolators
The JavaFX platform provides a set of standard interpolators that handles most
types of animation. The standard interpolators are defined in javafx.animation
.Interpolator . They are
Interpolator.DISCRETE
Interpolator.LINEAR
Interpolator.EASEIN
Interpolator.EASEOUT
Interpolator.EASEBOTH
Interpolator.SPLINE
The next few sections discuss each of these interpolators.
Discrete
A DISCRETE interpolator jumps instantaneously from one value to the next. The
target variable instantly assumes the target value when the key frame's time is
reached. This is the default interpolator if none is provided.
x => 1000 tween Interpolator.DISCRETE
Linear
A LINEAR interpolator changes the variable from the start value to the target
value at a constant rate of change over the time period. Using a vehicle's velocity
as an analogy, this would be the same as the vehicle traveling at a constant speed
over the time frame.
x => 1000 tween Interpolator.LINEAR
 
Search WWH ::




Custom Search