1.4.0 • Published 11 months ago

rain-char v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

npm.io

RainChar - Customizable Matrix-Style Rain Effect

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

RainChar is an animation effect written in JavaScript to create a Matrix-Style effect with full control over customizability.

Usage

Use CDN:

<script src="https://cdn.jsdelivr.net/npm/rain-char"></script>

Create an instance of the effect (all options are optional)

const rain = new RainChar({
    id: 'rain',
    font: 'Consolas',
    charSize: [10, 30]
});

To start the effect call the start method

rain.start();

Demo

m-sarabi.ir/rain-char A matrix-style image generator interface with options for font, character size, character range, background, foreground, speed, density factor, and resizing the effect screen.

Customization

You can customize the effect however you like with the options provided, and you can add an id to each effect individually to style them with CSS.

Most options (except for id and parentId) can be adjusted seamlessly at any time.

Options

NameDescriptionTypeDefault value
fontThe font used for Rain Charactersstring"monospace"
charSizeThe lower and upper limit for the font sizenumber, number10, 40
charRangeThe range of Unicode character, or a list of such rangesnumber, number or number, number0x0021, 0x007e
bgBackground color of the canvasstring"#222"
fgColor of the charactersstring"yellow"
idThe id to be assigned to the canvas elementstring
fpsMaximum fps (higher means faster rainfall)number30
densityFactorHow dense the rainfall is (Lower means denser)number10
trailMultiplierDefines the length of the trail. Higher means shorter trailnumber1
charSpacingDefines the space between characters (1 means one character)number1
charChangeFreqDefines the probability of characters changing (0% - 100%)number1
parentIdid of the element which canvas is appended tostringbody element

Methods

NameDescription
startFresh starts the effect animation. It also acts as a restart
stopStops the effect and clears the canvas.
pausePause/Play the animation.

By playing with the options above, you can create a variety of effects.

An example snow effect:

Changelog

Changelog

©️ Licence

This project is licensed under the MIT License

Copyright 2024 Mohammad Sarabi

1.4.0

11 months ago

1.3.0

11 months ago

1.2.0

11 months ago

1.1.0

11 months ago

1.0.9

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago