Rainbow Drops
How do I make an rainbow drops?
Randomly generated drops that fall and 'splatter' with gravity.Update: Added transparency based on fall height.. What is a rainbow drops? How do you make a rainbow drops? This script and codes were developed by Chris Barnes on 11 August 2022, Thursday.
Rainbow Drops - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rainbow Drops</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="tank">
<div id="box"></div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Rainbow Drops - Script Codes CSS Codes
body{
background-color:#fff;
}
#tank{ height:100px; width:500px; margin:0 auto; position:relative;
}
#box{ background-color:#000; position:absolute; top:102px; height:100px; width:100%; border-radius:5px;
}
span{ position:absolute; height:5px; width:5px; border-radius:10px; box-shadow:1px 1px 5px 1px rgba(0,0,0,.5);
}
.red{ background-color:#d94253
}
.orange{ background-color:#ff9900;
}
.green{ background-color:#73d932;
}
.blue{ background-color:#0099ff;
}
.purple{ background-color:#5309d2;
}
Rainbow Drops - Script Codes JS Codes
setInterval(function(){ var newDrop = document.createElement('span'); var drop_x = Math.floor(Math.random()*495+1); var drop_y = Math.floor(Math.random()*100+1); var temp = $(newDrop).appendTo('#tank').css({ left : drop_x + 'px', top : drop_y + 'px' }); if(drop_x < 100) { temp.addClass('red'); } else if(drop_x < 200) { temp.addClass('orange'); } else if(drop_x < 300) { temp.addClass('green'); } else if(drop_x < 400) { temp.addClass('blue'); } else if(drop_x < 500) { temp.addClass('purple'); } doStuff(temp, drop_y);
}, parseInt(($('#tank').children().length)/.01));
function doStuff(temp, drop_y){ var gravity = .1; var curr_speed = 1; var timer; timer = setInterval(function() { var pos = temp.position(); if(pos.top <= 97) { curr_speed += curr_speed * gravity; if(pos.top + curr_speed > 95) { temp.css('top', '100px'); } else { temp.css('top', '+='+curr_speed); } } else { var set_opac = drop_y/150; if(set_opac < .2) { set_opac = .2; } temp.animate({ height : curr_speed * 10 + 'px', width : Math.ceil(drop_y*6/100) + 1 + 'px', opacity: set_opac }, 300/curr_speed); setTimeout(function(){ temp.remove(); }, 20000); clearInterval(timer); } }, 10);
}
![Rainbow Drops - Script Codes](http://shots.codepen.io/csbarnes/pen/aHdAn-512.jpg)
Developer | Chris Barnes |
Username | csbarnes |
Uploaded | August 11, 2022 |
Rating | 4.5 |
Size | 2,365 Kb |
Views | 46,552 |
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!
Name | Size |
A Pen by Chris Barnes | 1,610 Kb |
Rainbow Drops 2 | 2,516 Kb |
The Last Question | 12,949 Kb |
3D CSS3 Cube | 4,179 Kb |
SCSS Loading Circle Mixin | 2,985 Kb |
CSS3 Selection Highlighting | 1,621 Kb |
ASCII Sentence Generator | 2,605 Kb |
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!
Name | Username | Size |
BenU Maintenance Site | Ksherman | 4,893 Kb |
Revolving Text Landing Page Trial | TimRuby | 2,976 Kb |
AngularJS Datalist Directive | M-e-conroy | 2,366 Kb |
Word Wrap Algorithm for Multiline Canvas Text | Peterhry | 2,349 Kb |
Search Box in Content Moves to Fixed Header | Chriscoyier | 2,768 Kb |
Simple animated hover effect | Pobee-norris | 3,044 Kb |
Materializecss input form | Jasonchan | 1,443 Kb |
Glowing Pulse Form | Jackrugile | 2,542 Kb |
Iron Man SVG Loading Animation | Andythayer | 3,069 Kb |
Angular Sandbox | Alexgurrola | 1,616 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!