• Stars
    star
    2,124
  • Rank 21,727 (Top 0.5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎬 Colorful animations in terminal output

chalk-animation

Build Status Version Codecov Downloads XO code style

Colorful animations in terminal output

Available animations

Name Preview
rainbow rainbow
pulse pulse
glitch glitch
radar radar
neon neon
karaoke karaoke

Install

$ npm i chalk-animation

Usage

import chalkAnimation from 'chalk-animation';

chalkAnimation.rainbow('Lorem ipsum dolor sit amet');

Start and stop

You can stop and resume an animation with stop() and start().

When created, the instance of chalkAnimation starts automatically.

const rainbow = chalkAnimation.rainbow('Lorem ipsum'); // Animation starts

setTimeout(() => {
    rainbow.stop(); // Animation stops
}, 1000);

setTimeout(() => {
    rainbow.start(); // Animation resumes
}, 2000);

Automatic stop

Anything printed to the console will stop the previous animation automatically

chalkAnimation.rainbow('Lorem ipsum');
setTimeout(() => {
    // Stop the 'Lorem ipsum' animation, then write on a new line.
    console.log('dolor sit amet');
}, 1000);

Changing speed

Change the animation speed using a second parameter. Should be greater than 0, default is 1.

chalkAnimation.rainbow('Lorem ipsum', 2); // Two times faster than default

Changing text

Change the animated text seamlessly with replace()

let str = 'Loading...';
const rainbow = chalkAnimation.rainbow(str);

// Add a new dot every second
setInterval(() => {
	rainbow.replace(str += '.');
}, 1000);

Manual rendering

Manually render frames with render(), or get the content of the next frame with frame()

const rainbow = chalkAnimation.rainbow('Lorem ipsum').stop(); // Don't start the animation

rainbow.render(); // Display the first frame

const frame = rainbow.frame(); // Get the second frame
console.log(frame);

CLI mode

# Install package globally
$ npm install --global chalk-animation
$ chalk-animation --help

  Colorful animations in terminal output

  Usage
    $ chalk-animation <name> [options] [text...]

  Options
    --duration  Duration of the animation in ms, defaults to Infinity
    --speed  Animation speed as number > 0, defaults to 1

  Available animations
    rainbow
    pulse
    glitch
    radar
    neon
    karaoke

  Example
    $ chalk-animation rainbow Hello world!

Related

License

MIT © Boris K

More Repositories

1

gradient-string

🌈 Beautiful color gradients in terminal output
JavaScript
1,030
star
2

vanity-eth

💎 Browser-based ETH vanity address generator
Vue
730
star
3

lyo

📦 Node.js to browser - The easy way
JavaScript
621
star
4

rgb-light-card

💡 A Lovelace custom card for RGB lights
JavaScript
414
star
5

nopaste

📋 Client-side paste service
JavaScript
362
star
6

linky

🔌 CLI tool to retrieve Linky smart meters data
TypeScript
216
star
7

ha-linky

📊 Home Assistant add-on for Linky smart meters
TypeScript
187
star
8

home-assistant-extension

📌 Home Assistant browser extension
Vue
169
star
9

git-history-editor

✏️ Online commit editor, intuitive and easy to use
HTML
160
star
10

github-stats-box

📌 Update a gist to contain your GitHub stats
JavaScript
139
star
11

gradient-badge

🍭 Badge generator with color gradient support
JavaScript
70
star
12

i3-config

🐍 A backup of my i3 config
Shell
59
star
13

conso-api

⚡ API for Linky smart meters
Vue
49
star
14

wakatime-to-toggl

📩 Push your WakaTime data to Toggl
JavaScript
35
star
15

linky-cli

⛔️ DEPRECATED - A CLI tool to retrieve your Linky power consumption
JavaScript
19
star
16

stravanity

👟 Easy to beat Strava segments
Vue
17
star
17

ha-history-stats

📈 Statistics about your Home Assistant history
Python
14
star
18

prettier-config

💜 My personal Prettier config & workflow
10
star
19

brackets-gofmt

📑 An extension for Brackets IDE to format Go code.
JavaScript
2
star
20

vanity-eth-cli

Works, but has nothing awesome
Go
1
star
21

blog-comments

1
star
22

bokub

📖 My profile's README
1
star
23

lyo-service

🌄 Lyo builder as a service
JavaScript
1
star