| 1 |
import QtQuick 2.0 |
| 2 |
|
| 3 |
Rectangle { |
| 4 |
width: 100 |
| 5 |
height: 100 |
| 6 |
color: "blue" |
| 7 |
|
| 8 |
RotationAnimation on rotation { |
| 9 |
duration: 3600 |
| 10 |
loops: Animation.Infinite |
| 11 |
from: 0 |
| 12 |
to: 360 |
| 13 |
} |
| 14 |
|
| 15 |
Timer { |
| 16 |
interval: 300 |
| 17 |
repeat: true |
| 18 |
running: true |
| 19 |
property int prevHit: -1 |
| 20 |
property int prevRotation: -1 |
| 21 |
onTriggered: { |
| 22 |
var date = new Date; |
| 23 |
var millis = date.getMilliseconds() |
| 24 |
|
| 25 |
if (prevHit < 0) { |
| 26 |
prevHit = millis; |
| 27 |
prevRotation = parent.rotation |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
var milliDelta = millis - prevHit; |
| 32 |
if (milliDelta <= 0) |
| 33 |
milliDelta += 1000; |
| 34 |
prevHit = millis; |
| 35 |
|
| 36 |
var delta = parent.rotation - prevRotation; |
| 37 |
if (delta < 0) |
| 38 |
delta += 360 |
| 39 |
prevRotation = parent.rotation |
| 40 |
console.log(milliDelta, delta, "ms/degrees "); |
| 41 |
} |
| 42 |
} |
| 43 |
} |