Sherzod Posted December 16, 2015 Posted December 16, 2015 Dear friends! Allow to present an interesting JS code. As you guessed, it is JS snow (and not only). Let's give our UniGUI application, a little "liven up" ... Example of use: 1. /files/snow.png 2. MainForm.Script... add: <script type="text/javascript"> //snow_img = "/files/snow.gif"; snow_img = "/files/snow.png"; // EXTRA: You can adjust the numbers of snowflakes you want on each page... snow_no = 15; if (typeof(window.pageYOffset) == "number") { snow_browser_width = window.innerWidth; snow_browser_height = window.innerHeight; } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { snow_browser_width = document.body.offsetWidth; snow_browser_height = document.body.offsetHeight; } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { snow_browser_width = document.documentElement.offsetWidth; snow_browser_height = document.documentElement.offsetHeight; } else { snow_browser_width = 500; snow_browser_height = 500; } snow_dx = []; snow_xp = []; snow_yp = []; snow_am = []; snow_stx = []; snow_sty = []; for (i = 0; i < snow_no; i++) { snow_dx[i] = 0; snow_xp[i] = Math.random() * (snow_browser_width - 50); snow_yp[i] = Math.random() * snow_browser_height; snow_am[i] = Math.random() * 20; snow_stx[i] = 0.02 + Math.random() / 10; snow_sty[i] = 0.7 + Math.random(); if (i > 0) document.write("<\div id=\"snow_flake" + i + "\" style=\"position:absolute;z-index:100000\"><\img src=\"" + snow_img + "\" border=\"0\"><\/div>"); else document.write("<\div id=\"snow_flake0\" style=\"position:absolute;z-index:100000\"><\/div>"); } function SnowStart() { for (i = 0; i < snow_no; i++) { snow_yp[i] += snow_sty[i]; if (snow_yp[i] > snow_browser_height - 50) { snow_xp[i] = Math.random() * (snow_browser_width - snow_am[i] - 30); snow_yp[i] = 0; snow_stx[i] = 0.02 + Math.random() / 10; snow_sty[i] = 0.7 + Math.random(); } snow_dx[i] += snow_stx[i]; document.getElementById("snow_flake" + i).style.top = snow_yp[i] + "px"; document.getElementById("snow_flake" + i).style.left = snow_xp[i] + snow_am[i] * Math.sin(snow_dx[i]) + "px"; } snow_time = setTimeout("SnowStart()", 10); } SnowStart(); </script> Try... Best regards. 4 Quote
Sherzod Posted December 27, 2023 Author Posted December 27, 2023 Towards the end of the year, I remember this post ❄️ 🙂 2 Quote
Fred Montier Posted December 30, 2023 Posted December 30, 2023 SherzodSnowflakes.mp4 Thanks to Sherzod for all the support a patience with all of us. Happy new year. PS: Please, allow me to use this code to my new book about JS + uniGUI for Script use in main form. Project521-SherzodSnowFlakes.rar 2 Quote
Sherzod Posted January 3 Author Posted January 3 On 12/27/2023 at 11:09 AM, Sherzod said: I remember this post ❄️ 🙂 ❄️ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.