Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.29 KB | None | 0 0
  1. import QtQuick 2.0
  2.  
  3. Item {
  4.     anchors.fill: parent
  5.     width: parent.width
  6.     height: parent.height
  7.         Canvas {
  8.             anchors.fill: parent
  9.             width: parent.width
  10.             height: parent.height
  11.             id: canvas
  12.  
  13.             property real angle: -Math.PI/2
  14.  
  15.             states: State {
  16.                 when: mouseArea.pressed
  17.                 PropertyChanges { angle: 5*Math.PI/2; target: canvas }
  18.                 //angle = 5*Math.PI/2;
  19.             }
  20.  
  21.             transitions: Transition {
  22.                 RotationAnimation {
  23.                     property: "angle"
  24.                     direction: RotationAnimation.Clockwise
  25.                     easing.type: Easing.InOutCubic
  26.                     duration: 700
  27.                 }
  28.             }
  29.  
  30.             MouseArea{
  31.                 id: mouseArea
  32.                 anchors.fill: parent
  33.             }
  34.  
  35.             onAngleChanged: requestPaint()
  36.  
  37.             onPaint: {
  38.                 var ctx = getContext("2d");
  39.                 ctx.reset();
  40.  
  41.                 ctx.strokeStyle = Qt.rgba(0, 0, 0, 1);
  42.                 ctx.lineWidth = 10;
  43.                 ctx.beginPath();
  44.                 ctx.arc(width/2, height/2, width/2-10, -Math.PI/2, angle);
  45.                 ctx.stroke();
  46.  
  47.             }
  48.         }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement