One of the appealing features of the Mac OS X operating system is its treatment of graphical reflection of objects on the desktop. As a modern development environment, JavaFX provides the tools and APIs to take advantage of popular effects, such as reflection. Before we conclude this chapter, we are going to explore how to use the Reflection class to create compelling graphical effects.
The Reflection
effect can be found in the package javafx.scene.effect
and is part of the Effect
API covered in the recipe Adding depth with lighting and shadow effects. If you are not familiar with how effects work in JavaFX, review that recipe.
To keep things simple, the next code snippet shows you how to apply reflection effects to objects on the scene. You can see the full code listing from ch03/source-code/src/effects/ReflectionEffect.fx
.
var grad = LinearGradient { startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0 proportional...