Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:19:57+00:00 2026-06-16T05:19:57+00:00

I visited the Stack Exchange Winter Bash website and I love the falling snow!

  • 0

I visited the Stack Exchange Winter Bash website and I love the falling snow! My question is, how can I recreate a similar effect that looks as nice. I attempted to reverse engineer the code to see if I could figure it out but alas no luck there. The JS is over my head. I did a bit of googling and came across some examples but they were not as elegant as the SE site or did not look very good.

Can anyone provide some instructions on how to replicate what the SE Winter Bash site creates or a place where I might learn how to do this?

Edit: I would like to replicate the effect as close as possible, IE: falling snow with snowflakes, and being able to move the mouse and cause the snow to move or swirl with the mouse moments.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:19:59+00:00Added an answer on June 16, 2026 at 5:19 am

    Great question, I actually wrote a snow plugin a while ago that I continually update see it in action. Also a link to the pure js source

    I noticed you tagged the question html5 and canvas, however you can do it without using either, and just standard elements with images or different background colors.

    Here’s two really simple ones I put together just now for you to mess with. The key in my opinion is using sin to get the nice wavy effect as the flakes fall. The first one uses the canvas element, the 2nd one uses regular dom elements.

    Since I’m absolutely addicted to canvas here’s a canvas version that performs quite nicely in my opinion.

    Canvas version

    Full Screen

    (function() {
        var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame ||
        function(callback) {
            window.setTimeout(callback, 1000 / 60);
        };
        window.requestAnimationFrame = requestAnimationFrame;
    })();
    
    
    var flakes = [],
        canvas = document.getElementById("canvas"),
        ctx = canvas.getContext("2d"),
        flakeCount = 200,
        mX = -100,
        mY = -100
    
        canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    
    function snow() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);
    
        for (var i = 0; i < flakeCount; i++) {
            var flake = flakes[i],
                x = mX,
                y = mY,
                minDist = 150,
                x2 = flake.x,
                y2 = flake.y;
    
            var dist = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)),
                dx = x2 - x,
                dy = y2 - y;
    
            if (dist < minDist) {
                var force = minDist / (dist * dist),
                    xcomp = (x - x2) / dist,
                    ycomp = (y - y2) / dist,
                    deltaV = force / 2;
    
                flake.velX -= deltaV * xcomp;
                flake.velY -= deltaV * ycomp;
    
            } else {
                flake.velX *= .98;
                if (flake.velY <= flake.speed) {
                    flake.velY = flake.speed
                }
                flake.velX += Math.cos(flake.step += .05) * flake.stepSize;
            }
    
            ctx.fillStyle = "rgba(255,255,255," + flake.opacity + ")";
            flake.y += flake.velY;
            flake.x += flake.velX;
    
            if (flake.y >= canvas.height || flake.y <= 0) {
                reset(flake);
            }
    
    
            if (flake.x >= canvas.width || flake.x <= 0) {
                reset(flake);
            }
    
            ctx.beginPath();
            ctx.arc(flake.x, flake.y, flake.size, 0, Math.PI * 2);
            ctx.fill();
        }
        requestAnimationFrame(snow);
    };
    
    function reset(flake) {
        flake.x = Math.floor(Math.random() * canvas.width);
        flake.y = 0;
        flake.size = (Math.random() * 3) + 2;
        flake.speed = (Math.random() * 1) + 0.5;
        flake.velY = flake.speed;
        flake.velX = 0;
        flake.opacity = (Math.random() * 0.5) + 0.3;
    }
    
    function init() {
        for (var i = 0; i < flakeCount; i++) {
            var x = Math.floor(Math.random() * canvas.width),
                y = Math.floor(Math.random() * canvas.height),
                size = (Math.random() * 3) + 2,
                speed = (Math.random() * 1) + 0.5,
                opacity = (Math.random() * 0.5) + 0.3;
    
            flakes.push({
                speed: speed,
                velY: speed,
                velX: 0,
                x: x,
                y: y,
                size: size,
                stepSize: (Math.random()) / 30,
                step: 0,
                angle: 180,
                opacity: opacity
            });
        }
    
        snow();
    };
    
    canvas.addEventListener("mousemove", function(e) {
        mX = e.clientX,
        mY = e.clientY
    });
    
    init();​
    

    Standard element version

    var flakes = [],
        bodyHeight = getDocHeight(),
        bodyWidth = document.body.offsetWidth;
    
    
    function snow() {
        for (var i = 0; i < 50; i++) {
            var flake = flakes[i];
    
            flake.y += flake.velY;
    
            if (flake.y > bodyHeight - (flake.size + 6)) {
                flake.y = 0;
            }
    
            flake.el.style.top = flake.y + 'px';
            flake.el.style.left = ~~flake.x + 'px';
    
            flake.step += flake.stepSize;
            flake.velX = Math.cos(flake.step);
    
            flake.x += flake.velX;
    
            if (flake.x > bodyWidth - 40 || flake.x < 30) {
                flake.y = 0;
            }
        }
        setTimeout(snow, 10);
    };
    
    
    function init() {
        var docFrag = document.createDocumentFragment();
        for (var i = 0; i < 50; i++) {
            var flake = document.createElement("div"),
                x = Math.floor(Math.random() * bodyWidth),
                y = Math.floor(Math.random() * bodyHeight),
                size = (Math.random() * 5) + 2,
                speed = (Math.random() * 1) + 0.5;
    
            flake.style.width = size + 'px';
            flake.style.height = size + 'px';
            flake.style.background = "#fff";
    
            flake.style.left = x + 'px';
            flake.style.top = y;
            flake.classList.add("flake");
    
            flakes.push({
                el: flake,
                speed: speed,
                velY: speed,
                velX: 0,
                x: x,
                y: y,
                size: 2,
                stepSize: (Math.random() * 5) / 100,
                step: 0
            });
            docFrag.appendChild(flake);
        }
    
        document.body.appendChild(docFrag);
        snow();
    };
    
    document.addEventListener("mousemove", function(e) {
        var x = e.clientX,
            y = e.clientY,
            minDist = 150;
    
        for (var i = 0; i < flakes.length; i++) {
            var x2 = flakes[i].x,
                y2 = flakes[i].y;
    
            var dist = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    
            if (dist < minDist) {
                rad = Math.atan2(y2, x2), angle = rad / Math.PI * 180;
    
                flakes[i].velX = (x2 / dist) * 0.2;
                flakes[i].velY = (y2 / dist) * 0.2;
    
                flakes[i].x += flakes[i].velX;
                flakes[i].y += flakes[i].velY;
            } else {
                flakes[i].velY *= 0.9;
                flakes[i].velX
                if (flakes[i].velY <= flakes[i].speed) {
                    flakes[i].velY = flakes[i].speed;
                }
            }
        }
    });
    
    init();
    
    function getDocHeight() {
        return Math.max(
        Math.max(document.body.scrollHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.documentElement.offsetHeight), Math.max(document.body.clientHeight, document.documentElement.clientHeight));
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I visited www.mysite.com and +1'd my website. I then visited mysite.com and the +1
though I have visited this site many times, this is my first question. After
I just visited this website , where I came acros this glowing menu (bottom
int dfs(int graph[MAXNODES][MAXNODES],int visited[],int start) { int stack[MAXNODES]; int top=-1,i; visited[start]=1; stack[++top]=start; while(top!=-1) {
Do you know some plug-in to visual studio , that can remember lines and
The full problem description I am trying to solve can be found here: https://i.stack.imgur.com/o1cFn.png
in stack-overflow, there's a badge called Enthusiast which is earned by Visited the site
I know the event show works for View stack i.e. I can use this
Consider the scenario: I visited a page of a website built using ASP.NET. The
How to print the IP address of a website in Android? I can run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.