Last active
August 29, 2015 14:06
-
-
Save valorcurse/f688baf5e6dcfd714e69 to your computer and use it in GitHub Desktop.
Testing rotation animations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.2 | |
import QtQuick.Window 2.1 | |
Window { | |
visible: true | |
width: 360 | |
height: 360 | |
MouseArea { | |
id: mouseArea | |
anchors.fill: parent | |
onClicked: { | |
rect.state = rect.state === "clicked" ? "" : "clicked"; | |
} | |
} | |
Rectangle { | |
id: rect | |
width: 50 | |
height: 50 | |
color: "blue" | |
anchors.centerIn: parent | |
function getRandom() { | |
var rand = Math.floor(Math.random() * 360) + 1; | |
console.log("Random: " + rand); | |
return rand; | |
} | |
states: [ | |
State { | |
name: "clicked" | |
PropertyChanges { | |
target: rect | |
rotation: getRandom() | |
} | |
} | |
] | |
transitions: Transition { | |
to: "clicked" | |
// PropertyAnimation { | |
// target: rect | |
// properties: "rotation" | |
// duration: 500 | |
// } | |
RotationAnimation { | |
target: rect | |
duration: 500 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment