Java Reference
In-Depth Information
JavaFX API documentation, we'll show a few example usages and suggest again
that the API documentation is the definitive source for further details. It turns out
that using text, with all its nooks and crannies, shows off the capabilities of light-
ing quite nicely. For example, Listing 6.2 is a complete code listing for display-
ing text with a DistantLight effect.
Listing 6.2
Displaying Text with a DistantLight Effect
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.effect.*;
import javafx.scene.effect.light.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.text.*;
function run() : Void {
Stage {
scene: Scene {
var text:Text;
content: [
Rectangle {
width: bind
text.layoutBounds.width + 30
height: bind
text.layoutBounds.height + 20
fill: Color.BLACK
},
text = Text {
x: 10, y: 10, textOrigin: TextOrigin.TOP
content: "DistantLight"
fill: Color.YELLOW
font: Font {
size: 72
}
effect: Lighting {
light: DistantLight {
azimuth: 90
elevation: 45
}
}
}
]
}
}
}
 
Search WWH ::




Custom Search