Advertisement
Guest User

Qt Quick 2 animation example

a guest
Feb 11th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. import QtQuick 2.0
  2. import QtMultimedia 5.0
  3.  
  4. Rectangle {
  5. id: window
  6. width: 1024
  7. height: 768
  8.  
  9. property bool vis: false
  10.  
  11. Item {
  12.  
  13. Repeater {
  14.  
  15. model: 500
  16.  
  17. Rectangle {
  18. visible: window.vis
  19. width: index
  20. height: index
  21. border.width: 1
  22. color: "yellow"
  23. z: 0
  24. }
  25. }
  26. }
  27.  
  28. Rectangle {
  29. id: overlayRect
  30. anchors.fill: parent
  31.  
  32. color: "black"
  33. }
  34.  
  35.  
  36. Column {
  37.  
  38. Rectangle {
  39. id: r
  40.  
  41. color: "black"
  42. width: 1024
  43. height: 733
  44.  
  45. // VideoOutput {
  46. // id: video
  47. // anchors.fill: parent
  48. // source: player
  49. // }
  50.  
  51.  
  52. Canvas {
  53. id: canvas
  54. anchors.fill: parent
  55. antialiasing: true
  56.  
  57. onPaint: {
  58. var context = canvas.getContext("2d")
  59. context.clearRect(0, 0, width, height)
  60. context.strokeStyle = "black"
  61. context.path = pathAnim.path
  62. context.stroke()
  63. }
  64. }
  65.  
  66. SequentialAnimation {
  67. running: true
  68. loops: -1
  69.  
  70. PauseAnimation { duration: 1000 }
  71. PathAnimation {
  72. id: pathAnim
  73.  
  74. duration: 2000
  75. easing.type: Easing.InQuad
  76.  
  77. target: box
  78. orientation: PathAnimation.RightFirst
  79. anchorPoint: Qt.point(box.width/2, box.height/2)
  80. path: Path {
  81. startX: 50; startY: 50
  82.  
  83. PathCubic {
  84. x: window.width - 50
  85. y: window.height - 50
  86.  
  87. control1X: x; control1Y: 50
  88. control2X: 50; control2Y: y
  89. }
  90.  
  91. onChanged: canvas.requestPaint()
  92. }
  93. }
  94. }
  95.  
  96. Rectangle {
  97. id: box
  98.  
  99. x: 25; y: 25
  100. width: 50; height: 50
  101. border.width: 1
  102. antialiasing: true
  103.  
  104. Text {
  105. anchors.centerIn: parent
  106. text: "Box"
  107. }
  108. }
  109. }
  110.  
  111.  
  112. Row {
  113. id: buttons
  114.  
  115. width: window.width
  116. height: 35
  117. spacing: 5
  118.  
  119. Rectangle {
  120. id: triggerButton
  121. color: "black"
  122.  
  123. width: 60
  124. height: 30
  125.  
  126. Text { text: "Trigger"; color: "white"; anchors.centerIn: parent }
  127. MouseArea { anchors.fill: parent; onClicked: { window.vis=(!window.vis);} }
  128. }
  129.  
  130. Rectangle {
  131. id: exitButton
  132. color: "black"
  133.  
  134. width: 60
  135. height: 30
  136.  
  137. Text { text: "Exit"; color: "white"; anchors.centerIn: parent }
  138. MouseArea { anchors.fill: parent; onClicked: { Qt.quit(); } }
  139. }
  140.  
  141. }
  142. }
  143.  
  144. // MediaPlayer {
  145. // id: player
  146. // source: "file:///home/user/sample.mpg"
  147. // autoPlay: false
  148. // }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement