aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Firefly.qml
blob: 7b65d8ecbc20bda969e8ab998d82cde36ba10701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import QtQuick 2.0
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0

Item {

  RectangularGlow {
    anchors.fill: fly
    glowRadius: Math.round(fly.radius /2)
    spread: 0.5
    color: Qt.rgba(1,1,1,0.3)
    cornerRadius: fly.radius + glowRadius
  }

  Rectangle {
    id: fly
    width: Math.round(Math.random()*canvas.width/200)+2
    height: width
    x: parent.x
    y: parent.y
    color: Qt.rgba(Math.random(),Math.random(),0,0.5)    
    radius: Math.floor(width/2)
    property int jitterX: Math.round(Math.random()*100)+10
    property int jitterY: Math.round(Math.random()*100)+10
     
    Behavior on color {
      ColorAnimation {
        duration: 500
      }
    }
   Behavior on x {
       SmoothedAnimation {
           velocity: 10+Math.random()*canvas.width/100
       }
   }
   Behavior on y {
       SmoothedAnimation {
           velocity: 10+Math.random()*canvas.height/100
       }
   }

  }


  
      Timer {
        interval: 5
         repeat: true
         running: true
         property bool starting: true
         onTriggered: {
              if(starting){ interval = Math.round(Math.random()*1000)+500; starting = false; }
              if ( (fly.x+fly.jitterX)>parent.width || (fly.x+fly.jitterX)<0 ){ fly.jitterX = 0-fly.jitterX }
              fly.x = fly.x+fly.jitterX
              if( (fly.y+fly.jitterY)>parent.height || (fly.y+fly.jitterY)<0 ){ fly.jitterY = 0-fly.jitterY }
              fly.y = fly.y+fly.jitterY
              fly.jitterX = (Math.round(Math.random())*2 - 1) *fly.jitterX
              fly.jitterY = (Math.round(Math.random())*2 - 1) *fly.jitterY
            fly.color = Qt.rgba(Math.random(),Math.random(),Math.random(),0.5)
           
         }
     } //end of timer
} //end of item
bgstack15