Rainbow rain

Developer
Size
2,171 Kb
Views
42,504

How do I make an rainbow rain?

What is a rainbow rain? How do you make a rainbow rain? This script and codes were developed by Matei Copot on 12 June 2022, Sunday.

Rainbow rain Previews

Rainbow rain - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>rainbow rain</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { background-color:black;
}
#c { opacity:.8;
}
canvas { position:absolute; top:0; left:0;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <canvas id=c></canvas>
<canvas id=bg></canvas> <script src="js/index.js"></script>
</body>
</html>

Rainbow rain - Script Codes CSS Codes

body { background-color:black;
}
#c { opacity:.8;
}
canvas { position:absolute; top:0; left:0;
}

Rainbow rain - Script Codes JS Codes

 //initial
var w = c.width = window.innerWidth, h = c.height = window.innerHeight, ctx = c.getContext('2d'), //parameters total = w, accelleration = .05, //afterinitial calculations size = w/total, occupation = w/total, repaintColor = 'rgba(0, 0, 0, .04)' colors = [], dots = [], dotsVel = [];
//setting the colors' hue
//and y level for all dots
var portion = 360/total;
for(var i = 0; i < total; ++i){ colors[i] = portion * i; dots[i] = h; dotsVel[i] = 10;
}
function anim(){ window.requestAnimationFrame(anim); ctx.fillStyle = repaintColor; ctx.fillRect(0, 0, w, h); for(var i = 0; i < total; ++i){ var currentY = dots[i] - 1; dots[i] += dotsVel[i] += accelleration; ctx.fillStyle = 'hsl('+ colors[i] + ', 80%, 50%)'; ctx.fillRect(occupation * i, currentY, size, dotsVel[i] + 1); if(dots[i] > h && Math.random() < .01){ dots[i] = dotsVel[i] = 0; } }
}
anim();
Rainbow rain - Script Codes
Rainbow rain - Script Codes
Home Page Home
Developer Matei Copot
Username towc
Uploaded June 12, 2022
Rating 4.5
Size 2,171 Kb
Views 42,504
Do you need developer help for Rainbow rain?

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!

Matei Copot (towc) Script Codes
Create amazing video scripts 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!