npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

rain-char

v2.2.0

Published

A modern, performant 'Matrix-style' falling character effect using Web Workers and Canvas.

Readme

RainChar - Customizable Matrix Rain Effect

NPM Version NPM Downloads npm bundle size jsDelivr hits (npm)

A dark background with flowing streams of Japanese characters in and green cascading downwards.

Bring the iconic, "Matrix" digital rain effect to your website with just a few lines of code.

This library is built with modern web technologies for maximum performance. It offloads all the heavy animation and rendering logic to a Web Worker, ensuring your main UI thread stays smooth and responsive.

➡️ Check out the live demo here! ⬅️

Play with all the settings and see it in action.

Rain Char Demo

Key Features

  • Blazing Fast: Uses OffscreenCanvas in a Web Worker to keep your main thread free.
  • Highly Customizable: Colors, character sets, font sizes, rain density, trail length, and more.
  • Easy to Use: A simple and clean API.
  • Responsive: Automatically observes and adapts to the new size.
  • Lightweight: No dependencies, just pure JavaScript.

💻 Quick Start

The easiest way to get started is by using the JSDelivr CDN.

1. CDN

Just add a <canvas> element to your HTML, and include the script.

<!DOCTYPE html>
<html>
<head>
    <title>Rain Char Demo</title>
</head>
<body>
    <canvas id="my-canvas"></canvas>

    <!-- Get the library from the CDN -->
    <script src="https://cdn.jsdelivr.net/npm/rain-char"></script>

    <script>
        // Find your canvas element
        const canvas = document.getElementById('my-canvas');

        // Create a new instance
        const rain = new RainChar(canvas);

        // Let it rain!
        rain.start();
    </script>

</body>
</html>

2. NPM / Yarn

If you're using a bundler like Vite, Webpack, or Rollup:

# Using npm
npm install rain-char

# Using yarn
yarn add rain-char

Then, you can import it into your project:

import RainChar from 'rain-char';

const canvas = document.querySelector('#my-canvas');

// Create a new instance with some custom settings
const rain = new RainChar(canvas, {
    fg: '#00ccff',
    density: 0.05,
    charRange: '0123456789',
});

// Let it rain!
rain.start();

⚙️ Configuration Options

You can pass a settings object as the second argument to the RainChar constructor. Here are all the available options:

| Option | Type | Default | Description | |------------------|------------------------------------------|--------------------|-------------------------------------------------------------------------------------------------| | font | string | 'monospace' | The CSS font-family to use for the characters. | | charSize | [number, number] | [10, 40] | The minimum and maximum font size for the characters. | | charRange | string | [number, number] | [][] | [0x0021, 0x007e] | Characters to use. Can be a string, a single Unicode range [min, max], or an array of ranges. | | bg | string | 'black' | Background color in a CSS-compatible format. | | fg | string | 'limegreen' | Font color in a CSS-compatible format. | | fps | number | 60 | The maximum frames per second for the animation. | | density | number | 0.2 | How dense the rain is (0 to 1). A larger value means more characters. | | trailDecay | number | 0.2 | The length of the character trails (0 to 1). A smaller value means a longer, more faded trail. | | charSpacing | number | 0.5 | The vertical gap between characters in a stream. 1 means they are tightly packed. | | charChangeFreq | number | 0.25 | How often characters change (0 to 1). A lower value means characters change less frequently. |

🕹️ API Methods

Here are the public methods you can call on your RainChar instance.

  • rain.start(): Starts or resumes the animation.

  • rain.pause(): Pauses the animation. Call start() to resume.

  • rain.stop(): Stops the animation and completely clears the canvas.

  • rain.updateSetting(key, value): Updates a single setting on the fly.

    // Make the rain trails longer
    rain.updateSetting('trailDecay', 0.05);
      
    // Change the color to a nice shade of blue
    rain.updateSetting('fg', '#3399FF');
  • rain.destroy(): Stops the animation, terminates the Web Worker, and cleans up all resources. Use this when you're removing the effect from the page permanently, to prevent memory leaks.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.


Created by Mohammad Sarabi.