When the ImageView , the Slider , and the other GUI controls are added to stage, and the
application is executed, it will look like what is shown in the next screenshot. In it, you can
see the reflection effect applied to the image.
How it works...
In the recipe Loading and displaying images with ImageView we have seen how to use the
Image API to load and display local or remote images. This recipe extends the code in that
recipe to not only load the image, but also apply effects and animations to it.
As shown in the previous screenshot, this version of the image browser includes a row of GUI
controls at the bottom of the screen that are used to apply different transformations and
effects to the loaded image. Let's take a closer look at how the code works:
F Scaling the image —using an instance of the Slider control you can dynamically
grow or shrink the image. To do this, we bind the properties ImageView.fitWidth
and ImageView.fitHeight to Slider.value . This causes the size of the image
to grow or shrink dynamically, while maintaining proper image aspect ratio. The
bound expression includes logic to ensure that the image does not grow excessively
large when it is scaled up as shown below:
fitWidth:bind if((slider.value*maxW) < w)
maxW * slider.value else w
fitHeight:bind if((slider.value*maxH) < h)
maxH * slider.value else h