Java Reference
In-Depth Information
Figure 6.7
Demonstrating a Text Node with a PointLight Lighting Effect
acceptable values for this variable is from 0 to 10, the default value being 1.5.
The PointLight effect for Figure 6.7 looks like this in JavaFX:
effect: Lighting {
light: PointLight {
x: 0 y: -500 z: 100
}
surfaceScale: 5
}
Finally, as SpotLight extends PointLight , it takes in the same instance vari-
ables as its parent and adds a few extras including the ability to define a vector—
a light source direction—in 3D space. SpotLight also lets you set the value of a
variable called specularExponent , which controls the focus of the light source and
accepts a value from 0 to 4. Figure 6.8 shows one example of how a SpotLight
effect can be applied to text.
Figure 6.8
Demonstrating a Text Node with a SpotLight Lighting Effect
In this case, the light source has been directed toward the end of the text, by vir-
tue of assigning the pointsAtX , pointsAtY , and pointsAtZ instance variables to
(400, 0, 0). This causes the dim letters at the beginning of the text. The preceding
effect is represented in JavaFX as follows:
effect: Lighting {
light: SpotLight {
x: 0 y: 150 z: 40
pointsAtX: 400 pointsAtY: 0 pointsAtZ: 0
specularExponent: 4
}
surfaceScale: 5
}
Search WWH ::




Custom Search