From 7abef431fda6e3bf1c78e235094c92f250a4a31f Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Tue, 24 Nov 2020 22:31:04 +0100 Subject: [PATCH] image, fall speed and rotation speed --- contents/images/snow1.png | Bin 0 -> 1431 bytes contents/ui/main.qml | 34 ++++++++++++++++++++++++++++------ contents/ui/snowWindow.qml | 30 ++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 contents/images/snow1.png diff --git a/contents/images/snow1.png b/contents/images/snow1.png new file mode 100644 index 0000000000000000000000000000000000000000..9ab4522d0e51143fd885fe58f29b7d518342ba62 GIT binary patch literal 1431 zcmV;I1!($-P))RI3?kS$iM&q03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00jF2GhW)~PmmWkt++MXMK(VCxGLQ<2!(DBEiTlu8>YEJP7b);Cf}n|9Nxv-8$*FYJrJ2eCH*+5q?haNpRkSl;|Y+ht>W zLj%5M?N1sWzYWy1eXkv9DN4X6#I7aatAO*)0*6IvqYXrVUW`8pOe78Put?~nLi03m z(Q#fC*bNK_h)eKa0s5@*NB~DkTHhJl+mw1P`J7vIggU_EBDp>X4=S{#xY0vAxUDkFXM>N*x z<|lxsfVW!kOv<>qc@f%PD~4-zNhjWe=3sy1U z6%c*E9;-}zM?f0casBn`=DQl4|Fv=Roxl;Pt*rHc7Yq)uv1DCoY0?PUn!${BfS1Ie zQyTl+SYw`@YO)nmutY|eZr0D9H$W}1+LOk(W-rihvHmsIwvpd=g>;(L#(GvEFdtK~ zGiao%S>QQ&Dr!3-sacZKVwHz^MTDQk>yoD@jMCCvTAjK!@oK3D_)@Gn4gAe&_t9HWd7C9yY@IK%@$M_=fdXsZh zf!7>MASE`>CJAuAW9+g-!lL6?MrqBq67YgaGDeLZ$;-MpUbUp9ZEFGNeWEh*P=E@` zNrY6a2123$yGZPw6{g-RnUqrBPOCsj`$WZt=xMoh?Hfjc(rpQqp(d-f#I|^LI>rVX zNX%F*4iBeP;RJ~R&mIPdjr>LdJT6Jr?{j?7s(D>@M#anUMgUw>PEGq9|4_g6fDo=2 zb46-Vvh-G?qDln_f|SzIlybG7bxIv&n$Xy7_wX3-CvZca4N^bLs;DkEm~%;KYFc%5 zF-d?u9eu#+G(<7)4x?623}DY&zY<}GQANwL)pSVA8tx&UZ?$sbhxzsP@OD<;_6>@N z;`%UcQD8H`yR5$1$h10HM~J8Xy&>5KL_~4g4MSlK0nfIQwp#V@F-xBghI#5uSizE$ z-2sJ7TS%);JdHS0KfC^C+W=o=?YC2-O}24bwGwNadK0wxy=6xTB6&uwotY>FdO!s2 lR#;aE@ip!LAEy1+?H`)IDjarQ>umr4002ovPDHLkV1ibin?e8p literal 0 HcmV?d00001 diff --git a/contents/ui/main.qml b/contents/ui/main.qml index f19618d..8881ec7 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -32,7 +32,7 @@ Item { id: root; property var snow: []; - readonly property int snowCount: 100; + readonly property int snowCount: 25; readonly property int screenWidth: Qt.application.screens[0].width; readonly property int screenHeight: Qt.application.screens[0].height; @@ -45,9 +45,6 @@ Item { onClicked: { - //var screenWidth = Qt.application.screens[0].width; - //var screenHeight = Qt.application.screens[0].height; - for (var i = 0; i < snowCount; i++) { var component = Qt.createComponent("snowWindow.qml"); @@ -56,7 +53,10 @@ Item { snow[i].x = Math.random() * screenWidth; snow[i].y = Math.random() * screenHeight; - + + snow[i].width = (Math.random() * 100) % snow[i].radius; + snow[i].height = snow[i].width; + snow[i].showMaximized(); } @@ -92,11 +92,33 @@ Item { snow[i].x = 1440; } - snow[i].y += 2; + //snow[i].y += 2; + snow[i].y += snow[i].fallingSpeed; if (snow[i].y > screenHeight) { + //snow[i].y = 0; + + snow[i].close(); + snow[i].destroy(); + + var component = Qt.createComponent("snowWindow.qml"); + snow[i] = component.createObject(root); + + snow[i].x = Math.random() * screenWidth; snow[i].y = 0; + snow[i].width = (Math.random() * 100) % snow[i].radius; + snow[i].height = snow[i].width; + + snow[i].showMaximized(); + } + + if(snow[i].rotationDirection == 0) { + snow[i].snowFlakeRotation += snow[i].rotationSpeed; + } else { + snow[i].snowFlakeRotation -= snow[i].rotationSpeed; + } + } } } diff --git a/contents/ui/snowWindow.qml b/contents/ui/snowWindow.qml index 56960fb..7273f6e 100644 --- a/contents/ui/snowWindow.qml +++ b/contents/ui/snowWindow.qml @@ -27,13 +27,17 @@ ApplicationWindow { id: root; property int dir: (Math.random() * 100) % 2; /* could go either left or right */ + property int radius: 100; /* size of snowflake */ property int swirl: (Math.random() * 1000) % 55 + 2; /* random falling 'swirl' */ property int disposition: 0; + property alias snowFlakeRotation: snowFlake.rotation; + property int rotationSpeed: (Math.random() * 100) % 3 + 1; /* falling rotation */ + property int rotationDirection: (Math.random() * 100) % 2; + property int fallingSpeed: (Math.random() * 100) % 3 + 2; - width: 3; height: 3; - //x: 500; y: 500; - opacity: 1; - //title: qsTr("Snowy") + //width: 80; height: 80; + opacity: 0.5; + color: "transparent"; flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint @@ -41,4 +45,22 @@ ApplicationWindow { | Qt.WA_TranslucentBackground | Qt.X11BypassWindowManagerHint; + Rectangle { + + id: snowFlake; + + anchors.fill: parent; + //radius: 3; + color: "transparent"; + + Image { + id: snowFlakeImage; + + anchors.fill: parent; + source: "../images/snow1.png"; + } + + } + + } -- 2.7.4