Lighting Effect (Spot Light as Source) - JavaFX

What is Lighting Effect (Spot Light as Source)?

On applying this impact to a node, a light is simulated on it, as if it is being generated through a spot light.

Spot Light Source − The light from this source attenuates in all instructions. The depth of the light relies upon on the distance of the object from the source.

Lighting Effect - (Spot Light as Source)


The class named light.Spot of the package javafx.scene.effect represents the remote light source. This class includes 4 properties, that are −

  • pointsAtX − This assets is of the type double and it represents the x coordinate of the course of vector for this light.
  • PointsAtY − This assets is of the type double and it represents the y coordinate of the course of vector for this light.
  • PointsAtZ − This assets is of the sort double and it represents the z coordinate of the course of vector for this light.
  • Specular Exponent − This assets is of the type double and it represents the specular exponent, which controls the focal point of this light source.

Example

The following program is an example demonstrating the lighting impact of JavaFX. In right here, we are drawing a text “Welcome to wisdomjobs” and a circle in a scene.

To these, we are applying the lighting effect, where the light is being emitted through a spotlight.

Save this code in a report with the name SpotLightExample.java.

Collect and execute the saved java file from the command prompt using the following commands.

On executing, the above program generates a JavaFX window as shown below

Lighting Effect - (Spot Light as Source)

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JavaFX Topics