Fireflies In The Night Sky

Developer
Size
3,327 Kb
Views
10,120

How do I make an fireflies in the night sky?

What is a fireflies in the night sky? How do you make a fireflies in the night sky? This script and codes were developed by David Dietle on 24 September 2022, Saturday.

Fireflies In The Night Sky Previews

Fireflies In The Night Sky - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Fireflies In The Night Sky</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="sky"> <s></s> <div class="fly"> <div class="eye"></div> <div class="leg"></div> <div class="leg"></div> <div class="leg"></div> <div class="leg"></div> <div class="wing"></div> <div class="light"></div> </div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Fireflies In The Night Sky - Script Codes CSS Codes

s { position: absolute; height: 2px; width: 2px; border-radius: 50%; z-index: 1; -webkit-filter: blur(1px); filter: blur(1px);
}
body { padding: 0px; margin: 0px; background-color: black; text-align: center; position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; overflow: hidden;
}
#sky { padding: 0px; margin: 0px; background: linear-gradient(to bottom, rgba(0,0,0,1) 0%,rgba(0,2,50,1) 100%); background-color: black; text-align: center; position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; overflow: hidden;
}
.light { position: absolute; border-radius: 50%; height: 10px; width: 10px; top: 14px; left: -3px; -webkit-filter: blur(5px), brightness(200%); filter: blur(5px), brightness(200%); background-color: lawngreen; z-index: 10000; animation: blinky 10s ease-in-out infinite;
}
.light:hover { box-shadow: 0 0 100px goldenrod !important;
}
.fly { display: none; background-color: rgb(30,30,30); position: absolute; height: 15px; width: 6.5px; top: 200px; left: 200px; border-radius: 30%; transform: rotateZ(-40deg); z-index: 300;
}
.fly.flip { transform: rotateZ(30deg) rotateY(180deg);
}
.fly .eye { width: 4px; height: 2px; content: ""; position: absolute; top: -4px; left: 0px; border-radius: 50%; background-color: darkslategray; z-index: 1000; transform: rotateZ(10deg);
}
.fly:after { width: 7px; height: 5px; content: ""; position: absolute; top: -4px; left: -3px; border-radius: 50%; background-color: inherit; transform-origin: bottom center; transform: rotateZ(30deg);
}
.fly:before { width: 6px; height: 12px; content: ""; position: absolute; top: 10px; left: 1.5px; border-radius: 50%; background-color: inherit; transform-origin: top center; transform: rotateZ(20deg);
}
.fly .leg { width: 6px; height: 1px; content: ""; position: absolute; top: 6px; left: -6px; border-radius: 1px; background-color: inherit; z-index: 1000; transform-origin: right; transform: rotateZ(-20deg);
}
.fly .leg:nth-child(2) { margin-top: -3px;
}
.fly .leg:nth-child(4) { margin-top: 3px;
}
.fly .wing { width: 8px; height: 24px; content: ""; position: absolute; top: 0px; left: 1px; border-radius: 50%; background-color: inherit; z-index: 1000; opacity: .5; transform-origin: top center; transform: rotateZ(-20deg); box-sizing: border-box; border: solid 1px aliceblue; animation: flap .1s linear infinite;
}
@keyframes flap { 0% { transform: rotateZ(-30deg) rotateX(10deg) rotateY(40deg); } 50% { transform: rotateZ(-50deg) rotateX(30deg) rotateY(80deg); } 100% { transform: rotateZ(-10deg) rotateX(0deg) rotateY(0deg); }
}
@keyframes blinky { 21%, 39%, 45%, 47%, 53% { opacity: .1; } 26%, 38%, 40%, 44%, 46%, 48% { opacity: 1; }
}
@keyframes fade { 0% { opacity: .1; } 10% { opacity: .4; } 20% { opacity: .8; } 30% { opacity: 1; } 70% { opacity: .8; } 80% { opacity: .4; } 90% { opacity: .1; } 100% { opacity: .0; }
}

Fireflies In The Night Sky - Script Codes JS Codes

$.coinFlip = function () { return Math.random() > .75;
}
var h;
var w;
$.move = function (firefly) { var left = $(firefly).position().left; var top = $(firefly).position().top; var size = $(firefly).outerWidth() + 10; var dirH = parseInt($(firefly).attr('dirH')); var dirV = parseInt($(firefly).attr('dirV')); if (left >= w - size - 10 || left <= 10) { dirH = -dirH; } if (top >= h - size - 10 || top <= 10) { dirV = -dirV; } if (dirH > 0) { $(firefly).addClass('flip'); } else { $(firefly).removeClass('flip'); } $(firefly).animate({ left: (left + dirH), top: (top + dirV) }, 'fast', 'linear', function () { setTimeout(function () { $.move(firefly); }, 1); }) .attr('dirH', dirH) .attr('dirV', dirV);
}
$.star = function () { var x = Math.max(Math.floor(Math.random() * w), 10); var y = Math.max(Math.floor(Math.random() * h), 10); var r = Math.max(Math.floor(Math.random() * 255), 200); var g = Math.max(Math.floor(Math.random() * 255), 200); var b = Math.max(Math.floor(Math.random() * 255), 200); var size = Math.max(Math.round(Math.random() * 3), 1); if (x >= w) { x = w - 10; } if (y >= h) { y = h - 10; } var star = $('s').first().clone(); $('#sky').append($(star)); $(star).css({ 'left': x + 'px', 'top': y + 'px', 'background-color': 'rgb(' + r + ',' + g + ',' + b + ')', }); if ($.coinFlip()) { var delay = Math.max(Math.round(Math.random() * 4000), 500); setTimeout(function () { $(star).css({ 'animation': 'fade 20s linear infinite' }); }, delay); } return star;
}
$.bug = function () { var multiple = Math.random() * 15; var dirH = Math.random() > .5 ? -multiple : multiple; var dirV = Math.random() > .5 ? -multiple : multiple; var r = Math.max(Math.floor(Math.random() * 255), 100); var g = Math.max(Math.floor(Math.random() * 255), 100); var b = Math.max(Math.floor(Math.random() * 255), 100); if (r == g) { b = 0; } else if (r == b) { g = 0; } else if (b == g) { r = 0; } var x = Math.max(Math.floor(Math.random() * w), 10); var y = Math.max(Math.floor(Math.random() * h), 10); if (x >= w) { x = w - 10; } if (y >= h) { y = h - 10; } var firefly = $('.fly').first().clone(); $('#sky').append($(firefly)); $(firefly).css({ 'left': x + 'px', 'top': y + 'px' }) .attr('dirH', dirH) .attr('dirV', dirV); $(firefly).find('.light').css({ 'background-color': 'rgb(' + r + ',' + g + ',' + b + ')', 'box-shadow': 'inset 0 0 20px rgb(' + r + ',' + g + ',' + b + '), 0 0 10px rgb(' + r + ',' + g + ',' + b + ')' }); $(firefly).fadeIn(); var delay = Math.max(Math.round(Math.random() * 1000), 500); setTimeout(function () { $(firefly).fadeOut('slow', 'linear', function () { $(firefly).remove(); }); $.move($.bug()); }, delay * 10); return firefly;
}
$(document).ready(function () { h = $('body').outerHeight(); w = $('body').outerWidth(); fireflies(); for (var i = 0; i < 300; i++) { $.star(); } $(window).resize(function () { h = $('body').outerHeight(); w = $('body').outerWidth(); var s = $('s').first().clone();
$('s').remove(); $('#sky').append(s); for (var i = 0; i < 300; i++) { $.star(); } });
});
function fireflies() { for (var i = 0; i < 10; i++) { var delay = Math.max(Math.round(Math.random() * 1000), 500); setTimeout(function () { $.move($.bug()); }, delay * 2); }
}
Fireflies In The Night Sky - Script Codes
Fireflies In The Night Sky - Script Codes
Home Page Home
Developer David Dietle
Username ddietle
Uploaded September 24, 2022
Rating 3.5
Size 3,327 Kb
Views 10,120
Do you need developer help for Fireflies In The Night Sky?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

David Dietle (ddietle) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!