| 1 |
// Copyright (C) 2018 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.9 |
| 5 |
import QtQuick.Window 2.2 |
| 6 |
import Qt.labs.lottieqt 1.0 |
| 7 |
|
| 8 |
Window { |
| 9 |
visible: true |
| 10 |
width: animContainer.width |
| 11 |
height: animContainer.height |
| 12 |
title: qsTr("Animation test") |
| 13 |
|
| 14 |
property bool showFps: false |
| 15 |
|
| 16 |
color: "black" |
| 17 |
|
| 18 |
Item { |
| 19 |
id: animContainer |
| 20 |
width: childrenRect.width |
| 21 |
height: childrenRect.height |
| 22 |
|
| 23 |
Repeater { |
| 24 |
model: 1 |
| 25 |
|
| 26 |
LottieAnimation { |
| 27 |
id: bmAnim |
| 28 |
|
| 29 |
x: 10 * index |
| 30 |
y: 10 * index |
| 31 |
loops: LottieAnimation.Infinite |
| 32 |
quality: LottieAnimation.MediumQuality |
| 33 |
source: "rect_rotate.json" |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
Text { |
| 39 |
id: text |
| 40 |
|
| 41 |
property real t |
| 42 |
property int frame: 0 |
| 43 |
|
| 44 |
anchors.right: parent.right |
| 45 |
color: "red" |
| 46 |
visible: showFps |
| 47 |
text: "FPS: " + fpsTimer.fps |
| 48 |
|
| 49 |
Timer { |
| 50 |
id: fpsTimer |
| 51 |
property real fps: 0 |
| 52 |
repeat: true |
| 53 |
interval: 1000 |
| 54 |
running: showFps |
| 55 |
onTriggered: { |
| 56 |
parent.text = "FPS: " + fpsTimer.fps |
| 57 |
fps = text.frame |
| 58 |
text.frame = 0 |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
NumberAnimation on t { |
| 63 |
id: tAnim |
| 64 |
from: 0 |
| 65 |
to: 1000 |
| 66 |
running: showFps |
| 67 |
loops: Animation.Infinite |
| 68 |
} |
| 69 |
|
| 70 |
onTChanged: { |
| 71 |
update() // force continuous animation |
| 72 |
text.frame++; |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
Rectangle { |
| 77 |
id: rot |
| 78 |
|
| 79 |
width: 10 |
| 80 |
height: 100 |
| 81 |
anchors.centerIn: parent |
| 82 |
color: "blue" |
| 83 |
enabled: showFps |
| 84 |
visible: enabled |
| 85 |
|
| 86 |
PropertyAnimation { |
| 87 |
target: rot |
| 88 |
property: "rotation" |
| 89 |
from: 0 |
| 90 |
to: 360 |
| 91 |
duration: 500 |
| 92 |
running: true |
| 93 |
loops: Animation.Infinite |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
PropertyAnimation { |
| 98 |
target: rot |
| 99 |
property: "rotation" |
| 100 |
from: 0 |
| 101 |
to: 360 |
| 102 |
duration: 500 |
| 103 |
running: true |
| 104 |
loops: Animation.Infinite |
| 105 |
} |
| 106 |
} |