Snowfall effect on Website (HTML,CSS,JS)

How to add snowfall effect on any website 

For adding snowfall effect on your website follow these simple steps
  1. Go to your blogger dashboard
  2. Now open layout option by clicking on three line
  3. Now add a HTML javascript gadget on bottom side or in Sidebar
  4. Copy this snowfall effect code and paste on content don't write anything in Title
  5. Now save this gadget and refresh your website
  6. Congratulations 🎉 you have successfully inplanted snowfall effect on your website 
 <canvas class='snow' id='snow'></div>

<style>
.snow{position:fixed;top:0;left:0;right:0;pointer-events:none;z-index:920}.contentz{height:100%;position:relative;overflow:hidden;z-index:1}


</style>

<script>!function(){function t(t){var n=t.getContext("2d"),e=0,i=0,o=[],d=function(){this.x=this.y=this.dx=this.dy=0,this.reset()};function a(){e=window.innerWidth,i=window.innerHeight,t.width=e,t.height=i,function(t){if(t!=o.length){o=[];for(var n=0;n<t;n++)o.push(new d)}}(e*i/1e4)}d.prototype.reset=function(){this.y=Math.random()*i,this.x=Math.random()*e,this.dx=1*Math.random()-.5,this.dy=.5*Math.random()+.5},a(),function t(){n.clearRect(0,0,e,i),n.fillStyle="rgba(255,255,255,.3)",o.forEach(function(t){t.y+=t.dy,t.x+=t.dx,t.y>i&&(t.y=0),t.x>e&&(t.reset(),t.y=0),n.beginPath(),n.arc(t.x,t.y,5,0,2*Math.PI,!1),n.fill()}),window.requestAnimationFrame(t)}(),window.addEventListener("resize",a)}var n;n=function(){t(document.getElementById("snow"))},"loading"!=document.readyState?n():document.addEventListener("DOMContentLoaded",n)}();</script>

 
Snowfall effect on Website (HTML,CSS,JS)

Features

The snowfall effect code snippet includes several features that enhance the visual appeal and behavior of the falling snowflakes on your website. Let's explore some of these features:


1. Realistic Snowfall: 

The code generates a realistic snowfall effect by animating multiple snowflake particles that descend from the top of the screen. Each snowflake is represented by a small circle drawn on the canvas.


2. Adjustable Density: 

The density of the snowflakes can be adjusted by modifying the `createParticles` function. By changing the count parameter, you can control the number of snowflake particles created, thereby controlling the density of the snowfall.


3. Randomized Snowflake Properties: 

Each snowflake particle has randomized properties such as position, velocity, and size. This randomness creates a natural and organic snowfall effect. The `reset` method of the `Particle` class is responsible for randomizing these properties each time a snowflake is reset or initially created.


4. Responsive Design:

 The snowfall effect adapts to different screen sizes and is responsive. When the window is resized, the `resizeCanvas` function is triggered, adjusting the size of the canvas and recreating the snowflake particles to fit the new dimensions. This ensures that the snowfall effect remains visually appealing on various devices and screen resolutions.


5. Performance Optimization: 

The snowfall effect is implemented efficiently to minimize performance impact. The `context.clearRect` method clears the canvas at each frame before redrawing the snowflakes, preventing visual artifacts and optimizing performance.


6. Transparency and Opacity:

 The snowflakes have a semi-transparent appearance, giving them a delicate and ethereal look. The `context.fillStyle` property sets the color and opacity of the snowflakes. You can modify the RGBA values to adjust the color and transparency of the snowflakes according to your preferences.


7. Smooth Animation:

 The snowflakes smoothly animate using the `window.requestAnimationFrame` method, which leverages the browser's rendering capabilities for optimal performance. The animation loop continuously updates the position of each snowflake and redraws them on the canvas, creating a smooth and realistic falling effect.


By incorporating these features, the snowfall effect code snippet provides an engaging and visually pleasing experience for your website visitors, evoking the enchantment of winter and the beauty of falling snowflakes

Next Post Previous Post
No Comment
Add Comment
comment url

Paid Templates

Blogger themes

Movie theme

codes for blogger

Grafix Material