tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 import Qt 4.7
       
     2 
       
     3 Rectangle {
       
     4     id: clock
       
     5     color: "gray"
       
     6     width: 200; height: 200
       
     7 
       
     8     property variant hours: 10
       
     9     property variant minutes: 28
       
    10     property variant seconds: 0
       
    11 
       
    12     Timer {
       
    13         interval: 1000; running: true; repeat: true; triggeredOnStart: true
       
    14         onTriggered: seconds++
       
    15     }
       
    16 
       
    17     Image { id: background; source: "content/clock.png" }
       
    18 
       
    19     Image {
       
    20         x: 92.5; y: 27
       
    21         source: "content/hour.png"
       
    22         smooth: true
       
    23         transform: Rotation {
       
    24             id: hourRotation
       
    25             origin.x: 7.5; origin.y: 73; angle: 0
       
    26             SpringFollow on angle {
       
    27                 spring: 2; damping: 0.2; modulus: 360
       
    28                 to: (clock.hours * 30) + (clock.minutes * 0.5)
       
    29             }
       
    30         }
       
    31     }
       
    32 
       
    33     Image {
       
    34         x: 93.5; y: 17
       
    35         source: "content/minute.png"
       
    36         smooth: true
       
    37         transform: Rotation {
       
    38             id: minuteRotation
       
    39             origin.x: 6.5; origin.y: 83; angle: 0
       
    40             SpringFollow on angle {
       
    41                 spring: 2; damping: 0.2; modulus: 360
       
    42                 to: clock.minutes * 6
       
    43             }
       
    44         }
       
    45     }
       
    46 
       
    47     Image {
       
    48         x: 97.5; y: 20
       
    49         source: "content/second.png"
       
    50         smooth: true
       
    51         transform: Rotation {
       
    52             id: secondRotation
       
    53             origin.x: 2.5; origin.y: 80; angle: 0
       
    54             SpringFollow on angle {
       
    55                 spring: 5; damping: 0.25; modulus: 360
       
    56                 to: clock.seconds * 6
       
    57             }
       
    58         }
       
    59     }
       
    60 
       
    61     Image {
       
    62         anchors.centerIn: background; source: "content/center.png"
       
    63     }
       
    64 }