Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <canvas id="snow_fall"></canvas>
              
            
!

CSS

              
                body {
    margin: 0;
    padding: 0;
    background: #000;
}
#snow_fall {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    top: 0;
    left: 0;
}
              
            
!

JS

              
                function snow_fall() {

  const canvas = document.getElementById('snow_fall');
  const ctx = canvas.getContext('2d');

  // Set the canvas size
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;

// Set Propoties
const numDots = 125;
const direction = 0.5;
const speed = .75;
const size = 3.5;
const dotColor = 'rgba(210,245,255,0.33)';

  // Set the initial dot positions
  const dots = [];
  for (let i = 0; i < numDots; i++) {
    dots.push({
      x: Math.random() * canvas.width,
      y: Math.random() * canvas.height,
    });
  }
  const rand = []
  for (i = 0; i < numDots; i++) {
    var random_num = Math.random() + 0.2;
    rand.push(random_num)
  }

  function drawDots() {
    
    // Clear the canvas
    ctx.clearRect(0, 0, canvas.width, canvas.height);
  
    // Draw
    for (let i = 0; i < numDots; i++) {
      ctx.beginPath();
      ctx.fillStyle = dotColor;
      ctx.arc(dots[i].x, dots[i].y, (rand[i] ** size) + (size / 1.5), 0, 2 * Math.PI);
      ctx.fill();
    }
  }

      function updateDots() {
      // Update the dot positions
        for (let i = 0; i < numDots; i++) {
          dots[i].y += (speed / 2) + ((Math.sin(rand[i]) * 1.25) * speed);
          dots[i].x += (Math.cos((dots[i].y * (Math.sqrt(speed) / speed / 10))) * ((Math.sqrt(Math.sqrt(speed) ** 1.3) - 0.15)) / 4) + direction;
          
          if (dots[i].y > canvas.height) {
            // Reset the dot position and speed
            dots[i].y = 0;
          } else if (dots[i].x > canvas.width) {
            dots[i].x = 0;
          }  else if (dots[i].x < 0) {
            dots[i].x = canvas.width;
          }
        }
      }

      // Animate the dots
      function animate() {
        // Update the dot positions
        updateDots();

        // Draw the dots
        drawDots();
        // Request the next animation frame
        requestAnimationFrame(animate);
      }

      // Start the animation
      animate();
}
snow_fall();
              
            
!
999px

Console