Git Product home page Git Product logo

m-sarabi / rain-char Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 921 KB

A lightweight JavaScript library that creates a 'Matrix-style' falling character effect with depth. Customize the font, colors, character range, and animation speed for dynamic visual effects on your webpage.

Home Page: http://m-sarabi.ir/rain-char/

License: MIT License

HTML 23.81% JavaScript 76.19%
canvas effect effects javascript animation-library cdn falling-code hacking jsdelivr library matrix visual-effects

rain-char's Introduction

RainChar - Customizable Matrix-Style Rain Effect

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

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

Name Description Type Default value
font The font used for Rain Characters string "monospace"
charSize The lower and upper limit for the font size [number, number] [10, 40]
charRange The range of Unicode character, or
a list of such ranges
[number, number] or
[number, number][]
[0x0021, 0x007e]
bg Background color of the canvas string "#222"
fg Color of the characters string "yellow"
id The id to be assigned to the canvas element string
fps Maximum fps (higher means faster rainfall) number 30
densityFactor How dense the rainfall is (Lower means denser) number 10
trailMultiplier Defines the length of the trail. Higher means shorter trail number 1
charSpacing Defines the space between characters (1 means one character) number 1
charChangeFreq Defines the probability of characters changing (0% - 100%) number 1
parentId id of the element which canvas is appended to string body element

Methods

Name Description
start Fresh starts the effect animation. It also acts as a restart
stop Stops the effect and clears the canvas.
pause Pause/Play the animation.

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

A snow effect example:

2024-08-25.20-39-35.mp4

Changelog

Changelog

©️ Licence

This project is licensed under the MIT License

Copyright 2024 Mohammad Sarabi

rain-char's People

Contributors

m-sarabi avatar

Stargazers

Pankaj avatar Tim Kersey avatar Joe Bordes avatar JohnsonB avatar Aleksandr Smyshliaev avatar Phillip Beazley avatar José Pablo Ramírez Vargas avatar  avatar

Watchers

 avatar

rain-char's Issues

Multiple character ranges

Description

Add the ability to specify multiple character ranges.

Suggested Solution

The current parameter takes a list of numbers. new system can be compatible with the current system.

  • If parameter is a [number, number] use the single character range format.
  • If the parameter is a [number, number][] use the multiple character range format.

Then use the format specified in the _getRandomChar() method.

Benefits

It will be possible to select wider ranges of characters without unwanted ones, For example when using Hiragana/Katakana, there are unused char codes that can be omitted this way

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.