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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ojdom/matrix-rain

v0.1.6

Published

Matrix Rain

Downloads

13

Readme

matrix-rain

matrix-rain is a library for generating customizable matrix rain effects. It comes with a built-in React component for ease of use, but you can use it without React if you want.

Installation

npm install @ojdom/matrix-rain

Usage

The library exports 2 files:

  • Matrix - a React component
  • MatrixController - a class that handles the functionality.

When not using React, you will only need to import the MatrixController

Create a MatrixController object and pass it the desired options.

  • Using React? Pass the MatrixController object to the React component as a prop. Make sure that the controller isn't replaced when the component is re-rendered!
  • Not using React? You will have to set a canvas element on the MatrixController. You can do this through the constructor or through the setCanvas() method.

Documentation

The MatrixController class has a number of methods that you can use to control the rain effect:

  • start() - starts the rain effect
  • disable() - disables the rain effect
  • stop() - stops the rain effect immediately

These methods will only work if a canvas has been set. When using the React component, this will be done automatically. When not using React, you will have to set a canvas element yourself. You can do this through the setCanvas() method or through the constructor.

The MatrixController constructor takes two arguments, both of which are optional:

  1. options - an object containing the desired options. Refer to the options section below for a list of available options.
  2. canvas - a canvas element. If this is omitted, the canvas will have to be set manually through the setCanvas() method.

Dimensions

The dimensions of the canvas are determined by the dimensions of its' container. When using the React component, you will need to pass the width and height of the container to the component as props.

When not using React, the canvas will automatically resize itself to the dimensions of its' container. Avoid padding on the canvas container!

React Component

The Matrix component has 3 required props:

  • controller - the MatrixController object to use
  • width - the width of the canvas
  • height - the height of the canvas

It also has 2 optional props:

  • auto - whether or not to automatically start the rain effect when the component is mounted. Defaults to false.
  • indicators - whether or not to show rudimentary control buttons. Defaults to false.

Options

The options object can contain the following options:

  • colors - an object containing 3 different values:
    • background - the canvas background color. Defaults to '#000'.
    • primary - the character color. Defaults to 'rgb(55, 255, 55)'.
    • flashed - the color of the character when it first appears. Defaults to '#fff'.
  • fontSize - the font size of the rain text. Defaults to 20.
  • fontFamily - the font family of the rain text. Defaults to 'roboto'.
  • chars - the characters to use in the rain text. Defaults to 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789@#$%^&()&^%+-/~{[|`]}'.
  • animationSpeed - the speed at which the rain animation occurs. Recommended range is 10-30. Defaults to 12.
  • dropPercentage - the percentage of the canvas that should be covered with rain. Recommended range is 10-75. Defaults to 25.
  • charChangeRate - the rate at which the characters change. Recommended range is 0-20. Defaults to 16.
  • opacityChangeRate - the rate at which the character opacity changes. Recommended range is 0-20. Defaults to 4.
  • fadedPercentage - the percentage of characters that should be faded. Recommended range is 0-50. Defaults to 25.
  • hiddenPercentage - the percentage of characters that should be hidden. Recommended range is 0-50. Defaults to 25.

Omitting part of the options object will result in the default value being used. Omitting the options object entirely will result in all default values being used.

Roadmap

  • Storybook is coming soon(tm).
  • Type support will come eventually.
  • Other functionality may be added in the future.