Java Reference
In-Depth Information
}
}
def text: Text = Text {
layoutX: bind (w - text.layoutBounds.width) / 2.0
layoutY: bind (h - text.layoutBounds.height) / 2.0
content: "Hello!"
font: Font.font("Arial", FontWeight.BOLD, 100);
fill: Color.SILVER
textOrigin: TextOrigin.TOP
}
def txtfx = ShapeSubtract {
a: bg
b: text
effect: DropShadow {
color: Color.rgb(0, 0, 0, 0.9)
offsetX: 5, offsetY: 5
radius: 10
}
fill: LinearGradient {
startX: 0, endX: 0, startY: 0, endY: 1
stops: [
Stop { offset: 0, color: Color.SILVER }
Stop { offset: 1, color: Color.WHITE }
]
}
}
When the code is rendered, it produces the text effect shown in the following screenshot.
How it works...
The code illustrates how you can combine the built-in visual effects available in JavaFX to
create new customized effects. In this recipe, we use the ShapeSubtract , DropShadow ,
and LinearGradient to build the cut-out text effect seen in the previous screenshot. Let's
examine how this works.
 
Search WWH ::




Custom Search