Warning, /utilities/kweather/src/qml/backgrounds/components/Stars.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Han Young <hanyoung@protonmail.com> 0003 * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 import QtQuick 0008 import QtQuick.Controls 0009 import QtQuick.Layouts 0010 import QtQuick.Shapes 0011 import org.kde.kirigami as Kirigami 0012 0013 Item { 0014 id: rootItem 0015 anchors.fill: parent 0016 property double starRadius: 1 0017 0018 property double opacityModifier: 0 0019 0020 NumberAnimation on opacityModifier { 0021 running: true 0022 to: 10000 0023 duration: Math.max(10000) 0024 onFinished: { 0025 if (rootItem.opacityModifier === 0) { 0026 to = 10000; 0027 } else { 0028 to = 0; 0029 } 0030 restart(); 0031 } 0032 } 0033 0034 Repeater { 0035 model: 30 0036 0037 Item { 0038 id: shape 0039 anchors.fill: rootItem 0040 0041 property double starModifier: { 0042 let num = 5000 * Math.random() 0043 if (num < 1000) { 0044 return 1000; 0045 } else { 0046 return num; 0047 } 0048 } 0049 0050 opacity: { 0051 let remainder = rootItem.opacityModifier % (2 * starModifier); 0052 if (remainder > starModifier) { // opacity is decreasing 0053 return (starModifier - (remainder % starModifier)) / starModifier; 0054 } else { // opacity is increasing 0055 return remainder / starModifier; 0056 } 0057 } 0058 0059 Rectangle { 0060 color: "#fff9c4" 0061 height: starRadius * 2 0062 width: height 0063 radius: width / 2 0064 x: Math.random() * rootItem.width 0065 y: Math.random() * rootItem.height 0066 } 0067 } 0068 } 0069 }