Java Reference
In-Depth Information
F Create the stencil —irst, we define a Rectangle instance (assigned to variable bg )
from which the letters will be cut out. Next, we create the text shapes using a Text
instance (assigned to variable text ) that will be extruded from the rectangle shape.
F Cut text out —to extract the text shapes from the rectangle, we use the
ShapeSubtract class to apply a shape subtraction operation, extracting the node
assigned to property a (the text node) from property b (the rectangle).
F Apply effects —subtracting the shapes from one another does not create the desired
effect. To make the effect more realistic, we apply a DropShadow effect to the
subtracted shape (rectangle with cutout letters). This adds depth to the text, making
the letters stand out as if they were cut out of the rectangle. To polish the effect, we
apply a linear gradient to the surface of the rectangle giving it a dusty metallic look.
See also
F Adding depth with lighting and shadow effects
F Applying cool paint effects with gradients
Adding visual appeal with the Reflection
effect
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.
Getting ready
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.
How to do it...
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: true
 
Search WWH ::




Custom Search