Java Reference
In-Depth Information
SpotLight: A SpotLight is much like a PointLight in that an X, Y, and Z location can be specified.
However, the SpotLight also has a sense of direction, and a point at which the light is shining can be
specified. A SpotLight is like a desk lamp or a flashlight, in that it produces a cone of light. When this
cone intersects a surface, it projects a very distinctive light pattern on to the surface.
Animating Light
Each of the light types provides unique opportunities for animation. The examples that follow explore
how you can use these light types to produce particular results. There is an additional example at the
end that shows how lighting can be combined with shadows to make some interesting animations. The
code in Listing 4-1 is the framework in which the examples are run.
Listing 4-1. Main.fx
var exampleGroup = Group{};
public function run():Void{
var sampleButton = Button{
text: "Sample Lights";
action: sampleLights;
var distantButton = Button{
text: "Distant Light";
action: distantLight;
var pointButton = Button{
text: "Point Light";
action: pointLight;
var spotButton = Button{
text: "Spot Light";
action: spotLight;
var withButton = Button{
text: "Shadow";
action: withShadow;
var topBox = HBox{
translateX: 48
translateY: 16
spacing: 32
content: [sampleButton, distantButton, pointButton, spotButton, withButton]
Stage {
title: "Chapter 4"
width: 640
Search WWH ::

Custom Search