Java Reference
In-Depth Information
sion, and applies a MotionBlur effect giving the appearance that the chevrons
are moving quickly to the right.
Scene {
var numChevrons = 8;
height: 50
width: (numChevrons+2)*20
content: [
Group {
effect: MotionBlur { radius: 12 angle: 0 }
content: for (i in [0..numChevrons]) {
Polyline {
points: [ 10+i*20, 10,
25+i*20, 25,
10+i*20, 40 ]
strokeWidth: 4
stroke: Color.RED
}
}
}
]
}
Figure 6.16 portrays what our chevron shapes look like before and after the
MotionBlur effect, which is in bold in the preceding code, is applied to them.
Figure 6.16
Chevron PolyLine Shapes Before and After a MotionBlur Effect Is Applied
Reflection
JavaFX comes equipped with an effect called Reflection , which, as its name
implies, renders a mirror image of your content below the original image. So, if
you want to add a reflection effect to the sphere represented by Figure 6.12, you
could do so with this single line of JavaFX code:
effect: Reflection { fraction: .75, topOffset: 3 }
This object literal defines two of Reflection 's instance variables. The fraction
variable represents what percentage of the original image is reflected below the
original image, in our case, 75%. The second variable, topOffset , defines
where, in numbers of pixels, the reflection effect should begin below the content.
Figure 6.17 shows what happens to our sphere when the effect is added to it.
 
Search WWH ::




Custom Search