Java Reference
In-Depth Information
val;
}
} else if( startValue instanceof Interpolatable) {
(startValue as Interpolatable).ofTheWay(
(endValue as Interpolatable),
j(frequency * fraction) * amplitude
);
} else {
// discrete
if (fraction == 1.0) endValue else startValue;
}
}
The function,
j()
, is the
Bessel
function.
Interpolatable
You may have noticed that we checked for the start and end value types and if
they were not numeric, we checked to see if they implemented Interpolatable.
The abstract class
javafx.animation.Interpolatable
allows a class to partic-
ipate in
Interpolation
even if that class is not inherently numerical. To do this,
the class must implement the function
ofTheWay(endVal:Object, t:Number) : Object
The classes
javafx.scene.paint.Color
and
javafx.scene.shape.Shape
are
two examples of JavaFX classes that implement
Interpolatable
.
Color
allows
the color to morph from the starting color to the end color by changing its red,
green, blue, and opacity a fractional amount toward the end color.
Shape
allows
the beginning shape to morph into the end shape.
Path-based animation is the concept of a graphical asset traveling along a path.
An example is a race car traveling along a race track, or a car driving within a
city.
Conceptually, path-based animation has two components: a graphical asset that
will travel the path, represented by a
javafx.scene.Node
class, and a route, rep-
resented by a
Path
,
javafx.scene.shape.Path
or
javafx.scene.shape.SVGPath
.
To create the actual animation, use the
javafx.animation.transistion.Path-
Transition
class. To illustrate this, let's use an example of an automobile travel-
ling the streets of midtown Manhattan in New York City.
Search WWH ::
Custom Search