Warning, /utilities/mycroft-plasmoid/plasmoid/contents/ui/TopBarAnim.qml is written in an unsupported language. File is not indexed.
0001 /* Copyright 2019 Aditya Mehra <aix.m@outlook.com> 0002 0003 This library is free software; you can redistribute it and/or 0004 modify it under the terms of the GNU Lesser General Public 0005 License as published by the Free Software Foundation; either 0006 version 2.1 of the License, or (at your option) version 3, or any 0007 later version accepted by the membership of KDE e.V. (or its 0008 successor approved by the membership of KDE e.V.), which shall 0009 act as a proxy defined in Section 6 of version 3 of the license. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Lesser General Public License for more details. 0015 0016 You should have received a copy of the GNU Lesser General Public 0017 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 import QtQuick 2.9 0021 import QtQuick.Layouts 1.3 0022 import org.kde.plasma.core 2.0 as PlasmaCore 0023 import org.kde.plasma.plasmoid 2.0 0024 import org.kde.plasma.components 2.0 as PlasmaComponents 0025 import org.kde.kirigami 2.5 as Kirigami 0026 0027 Item { 0028 0029 function startTalking() { 0030 animRunTime.running = true 0031 seqrun.running = true 0032 canvasmiddlegraphics.opacity = 1 0033 } 0034 0035 function stopTalking() { 0036 if(animRunTime.interval = 100){ 0037 animRunTime.running = false 0038 seqrun.running = false 0039 canvasmiddlegraphics.opacity = 0 0040 } 0041 } 0042 0043 0044 Timer{ 0045 id: animRunTime 0046 interval: 100 0047 repeat: true 0048 running: false 0049 onTriggered: { 0050 canvasmiddlegraphics.i += Math.PI/180 0051 canvasmiddlegraphics.amplitude += Math.PI/180 + Math.floor(Math.random() * 2) + 1 0052 canvasmiddlegraphics.amplitude -= Math.PI/180 + Math.floor(Math.random() * 2) + 1 0053 while(canvasmiddlegraphics.i >= Math.PI && canvasmiddlegraphics.amplitude >= Math.PI) canvasmiddlegraphics.i -= 2*Math.PI 0054 } 0055 } 0056 0057 0058 SequentialAnimation { 0059 id: seqrun 0060 0061 SequentialAnimation { 0062 loops: 10 0063 0064 ParallelAnimation { 0065 NumberAnimation{ 0066 target: canvasmiddlegraphics 0067 property: "amplitude" 0068 from: 0 0069 to: 10 + Math.floor(Math.random() * 6) + 1 0070 duration: 12 0071 } 0072 } 0073 0074 ParallelAnimation { 0075 NumberAnimation{ 0076 target: canvasmiddlegraphics 0077 property: "amplitude" 0078 from: 10 0079 to: 16 + Math.floor(Math.random() * 2) + 1 0080 duration: 12 0081 } 0082 } 0083 0084 ParallelAnimation{ 0085 NumberAnimation{ 0086 target: canvasmiddlegraphics 0087 property: "amplitude" 0088 from: 16 + Math.floor(Math.random() * 2) + 1 0089 to: 10 + Math.floor(Math.random() * 6) + 1 0090 duration: 12 0091 } 0092 } 0093 0094 ParallelAnimation { 0095 NumberAnimation{ 0096 target: canvasmiddlegraphics 0097 property: "amplitude" 0098 from: 10 + Math.floor(Math.random() / 6) + 1 0099 to: 0 0100 duration: 12 0101 } 0102 } 0103 } 0104 } 0105 0106 Canvas { 0107 id:canvasmiddlegraphics 0108 width: parent.width 0109 height: Kirigami.Units.gridUnit * 2 0110 anchors.centerIn: parent 0111 visible: true 0112 0113 property color strokeStyle: Qt.darker(fillStyle, 1.5) 0114 property color fillStyle: Qt.darker(theme.linkColor, 1.1) 0115 property real lineWidth: 5 0116 property bool fill: true 0117 property bool stroke: true 0118 property real alpha: 1.0 0119 property real scale : 1 0120 property real rotate : 0 0121 property real i: 0 0122 property real waveSpeed: 10 0123 property real amplitude: 0 0124 antialiasing: true 0125 smooth: true 0126 opacity: 0 0127 0128 onIChanged: requestPaint(); 0129 0130 renderTarget: Canvas.FramebufferObject 0131 renderStrategy: Canvas.Cooperative 0132 0133 0134 onPaint: { 0135 var ctxside = canvasmiddlegraphics.getContext('2d'); 0136 var hCenter = width * 0.5 0137 var vCenter = height * 0.5 0138 var size = 12 0139 var period = 15; 0140 var dotSpeed = 5; 0141 0142 function draw_line(i){ 0143 var oStartx=0; 0144 var oStarty=( height / 2 ) 0145 ctxside.beginPath(); 0146 ctxside.moveTo( oStartx, oStarty + amplitude * Math.sin( x / period + ( i / 5 ) ) ); 0147 ctxside.lineWidth = 1; 0148 ctxside.strokeStyle = theme.linkColor; 0149 0150 for(var Vx = oStartx; Vx < width * 0.95; Vx++) { 0151 var Vy = amplitude * Math.sin( Vx / period + ( i / 5 + Math.floor(Math.random() * 2) + 0)); 0152 ctxside.lineTo( oStartx + Vx, oStarty + Vy); 0153 } 0154 0155 ctxside.stroke(); 0156 } 0157 0158 0159 function render(){ 0160 var st = i 0161 ctxside.clearRect(0, 0, width, height); 0162 draw_line(st) 0163 } 0164 render(); 0165 } 0166 } 0167 }