diff options
Diffstat (limited to 'examples/declarative/animations')
-rw-r--r-- | examples/declarative/animations/color-animation.qml | 70 | ||||
-rw-r--r-- | examples/declarative/animations/easing.qml | 99 | ||||
-rw-r--r-- | examples/declarative/animations/images/face-smile.png | bin | 0 -> 15408 bytes | |||
-rw-r--r-- | examples/declarative/animations/images/moon.png | bin | 0 -> 2433 bytes | |||
-rw-r--r-- | examples/declarative/animations/images/shadow.png | bin | 0 -> 425 bytes | |||
-rw-r--r-- | examples/declarative/animations/images/star.png | bin | 0 -> 349 bytes | |||
-rw-r--r-- | examples/declarative/animations/images/sun.png | bin | 0 -> 8153 bytes | |||
-rw-r--r-- | examples/declarative/animations/property-animation.qml | 64 |
8 files changed, 233 insertions, 0 deletions
diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml new file mode 100644 index 0000000..54608c7 --- /dev/null +++ b/examples/declarative/animations/color-animation.qml @@ -0,0 +1,70 @@ +import Qt 4.6 + +Item { + id: window + width: 640; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { + position: 0.0 + color: SequentialAnimation { + running: true; repeat: true + ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } + ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } + } + } + GradientStop { + position: 1.0 + color: SequentialAnimation { + running: true; repeat: true + ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } + ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } + } + } + } + } + + // the sun, moon, and stars + Item { + width: parent.width; height: 2 * parent.height + transformOrigin: Item.Center + rotation: NumberAnimation { from: 0; to: 360; duration: 10000; running: true; repeat: true } + Image { + source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter + transformOrigin: Item.Center; rotation: -3 * parent.rotation + } + Image { + source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter + transformOrigin: Item.Center; rotation: -parent.rotation + } + Particles { + x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 + source: "images/star.png"; angleDeviation: 360; velocity: 0 + velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 + opacity: SequentialAnimation { + running: true; repeat: true + NumberAnimation { from: 0; to: 1; duration: 5000 } + NumberAnimation { from: 1; to: 0; duration: 5000 } + } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { + position: 0.0 + color: SequentialAnimation { + running: true; repeat: true + ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } + ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } + } + } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } +} diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml new file mode 100644 index 0000000..a9ba05f --- /dev/null +++ b/examples/declarative/animations/easing.qml @@ -0,0 +1,99 @@ +import Qt 4.6 + +Rectangle { + id: window + width: 600; height: 460; color: "#232323" + + ListModel { + id: easingTypes + ListElement { type: "easeLinear"; ballColor: "DarkRed" } + ListElement { type: "easeInQuad"; ballColor: "IndianRed" } + ListElement { type: "easeOutQuad"; ballColor: "Salmon" } + ListElement { type: "easeInOutQuad"; ballColor: "Tomato" } + ListElement { type: "easeOutInQuad"; ballColor: "DarkOrange" } + ListElement { type: "easeInCubic"; ballColor: "Gold" } + ListElement { type: "easeOutCubic"; ballColor: "Yellow" } + ListElement { type: "easeInOutCubic"; ballColor: "PeachPuff" } + ListElement { type: "easeOutInCubic"; ballColor: "Thistle" } + ListElement { type: "easeInQuart"; ballColor: "Orchid" } + ListElement { type: "easeOutQuart"; ballColor: "Purple" } + ListElement { type: "easeInOutQuart"; ballColor: "SlateBlue" } + ListElement { type: "easeOutInQuart"; ballColor: "Chartreuse" } + ListElement { type: "easeInQuint"; ballColor: "LimeGreen" } + ListElement { type: "easeOutQuint"; ballColor: "SeaGreen" } + ListElement { type: "easeInOutQuint"; ballColor: "DarkGreen" } + ListElement { type: "easeOutInQuint"; ballColor: "Olive" } + ListElement { type: "easeInSine"; ballColor: "DarkSeaGreen" } + ListElement { type: "easeOutSine"; ballColor: "Teal" } + ListElement { type: "easeInOutSine"; ballColor: "Turquoise" } + ListElement { type: "easeOutInSine"; ballColor: "SteelBlue" } + ListElement { type: "easeInExpo"; ballColor: "SkyBlue" } + ListElement { type: "easeOutExpo"; ballColor: "RoyalBlue" } + ListElement { type: "easeInOutExpo"; ballColor: "MediumBlue" } + ListElement { type: "easeOutInExpo"; ballColor: "MidnightBlue" } + ListElement { type: "easeInCirc"; ballColor: "CornSilk" } + ListElement { type: "easeOutCirc"; ballColor: "Bisque" } + ListElement { type: "easeInOutCirc"; ballColor: "RosyBrown" } + ListElement { type: "easeOutInCirc"; ballColor: "SandyBrown" } + ListElement { type: "easeInElastic"; ballColor: "DarkGoldenRod" } + ListElement { type: "easeOutElastic"; ballColor: "Chocolate" } + ListElement { type: "easeInOutElastic"; ballColor: "SaddleBrown" } + ListElement { type: "easeOutInElastic"; ballColor: "Brown" } + ListElement { type: "easeInBack"; ballColor: "Maroon" } + ListElement { type: "easeOutBack"; ballColor: "LavenderBlush" } + ListElement { type: "easeInOutBack"; ballColor: "MistyRose" } + ListElement { type: "easeOutInBack"; ballColor: "Gainsboro" } + ListElement { type: "easeOutBounce"; ballColor: "Silver" } + ListElement { type: "easeInBounce"; ballColor: "DimGray" } + ListElement { type: "easeInOutBounce"; ballColor: "SlateGray" } + ListElement { type: "easeOutInBounce"; ballColor: "DarkSlateGray" } + } + + Component { + id: delegate + + Item { + height: 42; width: window.width + Text { text: type; anchors.centerIn: parent; color: "White" } + Rectangle { + id: slot1; color: "#121212"; x: 30; height: 32; width: 32 + border.color: "#343434"; border.width: 1; radius: 8; anchors.verticalCenter: parent.verticalCenter + } + Rectangle { + id: slot2; color: "#121212"; x: window.width - 62; height: 32; width: 32 + border.color: "#343434"; border.width: 1; radius: 8; anchors.verticalCenter: parent.verticalCenter + } + Rectangle { + id: rect; x: 30; color: "#454545" + border.color: "White"; border.width: 2 + height: 32; width: 32; radius: 8; anchors.verticalCenter: parent.verticalCenter + + MouseRegion { + onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' + anchors.fill: parent + } + + states : State { + name: "right" + PropertyChanges { target: rect; x: window.width - 62; color: ballColor } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { matchProperties: "x"; easing: type; duration: 1000 } + ColorAnimation { matchProperties: "color"; easing: type; duration: 1000 } + } + } + } + } + } + + Flickable { + anchors.fill: parent; viewportHeight: layout.height + Column { + id: layout + anchors.left: parent.left; anchors.right: parent.right + Repeater { model: easingTypes; delegate: delegate } + } + } +} diff --git a/examples/declarative/animations/images/face-smile.png b/examples/declarative/animations/images/face-smile.png Binary files differnew file mode 100644 index 0000000..3d66d72 --- /dev/null +++ b/examples/declarative/animations/images/face-smile.png diff --git a/examples/declarative/animations/images/moon.png b/examples/declarative/animations/images/moon.png Binary files differnew file mode 100644 index 0000000..9407b2b --- /dev/null +++ b/examples/declarative/animations/images/moon.png diff --git a/examples/declarative/animations/images/shadow.png b/examples/declarative/animations/images/shadow.png Binary files differnew file mode 100644 index 0000000..8270565 --- /dev/null +++ b/examples/declarative/animations/images/shadow.png diff --git a/examples/declarative/animations/images/star.png b/examples/declarative/animations/images/star.png Binary files differnew file mode 100644 index 0000000..27ef924 --- /dev/null +++ b/examples/declarative/animations/images/star.png diff --git a/examples/declarative/animations/images/sun.png b/examples/declarative/animations/images/sun.png Binary files differnew file mode 100644 index 0000000..7713ca5 --- /dev/null +++ b/examples/declarative/animations/images/sun.png diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml new file mode 100644 index 0000000..0256137 --- /dev/null +++ b/examples/declarative/animations/property-animation.qml @@ -0,0 +1,64 @@ +import Qt 4.6 + +Item { + id: window + width: 320; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { position: 0.0; color: "DeepSkyBlue" } + GradientStop { position: 1.0; color: "LightSkyBlue" } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + // The shadow for the smiley face + Image { + anchors.horizontalCenter: parent.horizontalCenter + source: "images/shadow.png"; y: smiley.minHeight + 58 + transformOrigin: Item.Center + + // The scale property depends on the y position of the smiley face. + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + source: "images/face-smile.png"; y: minHeight + + // Animate the y property. Setting repeat to true makes the + // animation repeat indefinitely, otherwise it would only run once. + y: SequentialAnimation { + running: true; repeat: true + + // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing: "easeOutExpo"; duration: 300 + } + + // Then move back to minHeight in 1 second, using the easeOutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing: "easeOutBounce"; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} |