Working with color transitions

The following transitions fall into this category: FadeTransition, FillTransition, and StrokeTransition.

The FillTransition transition makes a smooth change between two colors:

// chapter5/transitions/ColorTransitionsDemo.javaShape circle = new Circle(50, 150, 50);FillTransition ft = new FillTransition(Duration.seconds(3), circle, Color.RED, Color.BLUE);ft.play();

Intermediate values are calculated based on RGB and opacity numerical components of the Color through a special interpolator.

To make the Animation API aware of the interpolator support, the Color implements an Interpolatable interface, which you can use for your own components as well:

public interface Interpolatable<T> { public T interpolate(T endValue, ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.