Java Reference
In-Depth Information
var anim = Timeline{
repeatCount: Timeline.INDEFINITE
autoReverse: true
keyFrames: [
KeyFrame{time: 0s, values: elev=>0.0},
KeyFrame{time: 5s, values: elev=>180.0},
KeyFrame{time: 7.5s, values: elev=>160.0},
KeyFrame{time: 7.5s, values: azim=>0.0},
KeyFrame{time: 12.5s, values: azim=>360.0}
]
}
var text = Text{
content: "Example Text"
font: Font{
size: 78
}
fill: Color.GRAY
}
var group = Group{
content:text
effect:lighting
translateX: 640/2.0 - text.boundsInParent.width/2.0
translateY: 480/2.0
}
anim.play();
insert group into exampleGroup.content;
}
The code creates a lighting effect and applies it to a group containing some sample text. The
lighting variable has its light property set to a DistantLight . The properties azimuth and elevation of
the DistantLight are bound to the variables azim and elev . A Timeline is created called anim that adjusts
the values of elev and azim over a 12.5-second animation. The animation is set to reverse and play
forever.
First, the animation increases the elevation of the DistantLight from 0.0 to 180.0, which is like
watching the sun rise on the right, travel across the sky, and set on the left. The next part of the
animation has the DistantLight move to 160.0 degrees, which is equivalent to the light being raised 30
degrees from the left horizon. Then, the DistantLight is rotated a full 360.0 degrees around the scene.
This example shows how a DistantLight can make text look believably 3D; it also shows how the
animation of this light increases the fidelity of the 3D effect.
Point Light Example
In this example, a point light is animated over the surface of a simple rectangle. The screenshot in
Figure 4-4 shows one frame of the animation.
Search WWH ::




Custom Search