Java Reference
In-Depth Information
How to do it...
The abbreviated code listing given next shows you how to use the Lighting and the
DropShadow effects to enhance the appearance of a circle and a rectangle. You can
find the the full listing in ch03/source-code/src/effects/ShapeEffectDemo.fx .
def shadow = DropShadow { offsetX:5 offsetY:5 }
def light = Lighting {
light:DistantLight{azimuth:-45}
surfaceScale:5
}
def circ = Circle {
centerX: 125 centerY: 100 radius:50
fill:Color.RED stroke:Color.BLUE
effect: light
}
def rect = Rectangle {
x:200 y:50 width:125 height:100
fill:Color.BLUE
arcHeight:10 arcWidth:10
effect: shadow
}
The code snippet produces the objects shown in the next figure.
How it works...
As mentioned earlier, all Node instances expose the effect:Effect property. An Effect
class provides algorithmic manipulation to the input source to produce new graphical
elements with the applied effects during rendition of the scene graph. In this recipe, we use
the Lighting and the DropShadow effects to add depth to the the objects on the scene.
Let's see how these effects work.
 
Search WWH ::




Custom Search