Using Spot light

The Light.Spot class imitates a real-life spotlight—you can choose its location, the direction, and the light style and JavaFX will  apply the corresponding lighting to your nodes.

The actual results are easier to understand in a dynamic form, so I've prepared a demonstration that allows all parameters to be tweaked:

Its listing is too long for the book; please find it on the book's GitHub. I'll provide only spotlight creation here:

// chapter8/light/SpotLightDemo.javaLight.Spot light = new Light.Spot(200, 150, 500, 1, Color.WHITE);light.setPointsAtX(100);light.setPointsAtY(100);light.setPointsAtZ(0);

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.