How it works...

The animator type can be used just like any other animation type. We want to scale a rectangle from a size of 5 to a size of 1 within 2,000 milliseconds (2 seconds). We created a blue Rectangle object and added a scale animator to it. We set the initial value to 5 and the final value to 1. Then, we set the animation duration to 2000 and set the running value to true so that it will be played when the program starts.

Just like the animation types, animators can also be put into groups (that is, parallel animation groups or sequential animation groups). An animation group will also be treated as an animator by QtQuick and be run on the scene graph's rendering thread whenever possible. In step 2, we want to group two different animators into a parallel animation group so that they run together at the same time.

We will keep the scale animator we created previously and add another rotation animator to rotate the Rectangle object. This time, set the running value in the parallel animation group, but not in any of the individual animators.

Just like the C++ version, QML also supports easing curves, and they can be easily applied to any of the animations or animator types.

There is something called animator in QML, which is different from the usual animation type, even though there is some similarity between them. Unlike regular animation types, animator types are directly operated on Qt Quick's scene graph, rather than the QML objects and their properties. The value of the QML property will not be changed while the animation is running, as it will only change once the animation is finished. The benefits of using the animator type is that it operates directly on the scene graph's rendering thread, which means its performance will be slightly better than running on the UI thread.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset