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.java
Shape 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, double t);
}

The StrokeTransition transition works the same way as FillTransition but on the stroke of the Shape (the outer border; see Chapter 2, Building Blocks – Shapes, Text, and Controls).

The FadeTransition transition changes the opacity property of the Node.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.139.224