Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bokub/chalk-animation
:clapper: Colorful animations in terminal output
https://github.com/bokub/chalk-animation
animation chalk color console nodejs npm-package terminal
Last synced: about 4 hours ago
JSON representation
:clapper: Colorful animations in terminal output
- Host: GitHub
- URL: https://github.com/bokub/chalk-animation
- Owner: bokub
- License: mit
- Created: 2017-07-21T14:57:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-13T10:59:52.000Z (about 2 years ago)
- Last Synced: 2024-11-28T05:02:44.146Z (14 days ago)
- Topics: animation, chalk, color, console, nodejs, npm-package, terminal
- Language: JavaScript
- Homepage:
- Size: 807 KB
- Stars: 2,136
- Watchers: 11
- Forks: 72
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- starred - bokub/chalk-animation - :clapper: Colorful animations in terminal output (JavaScript)
- awesome-github-star - chalk-animation
- awesome - chalk-animation - Colorful animations in terminal stdout (Packages / Console)
- awesome-cli - chalk-animation - Colorful animations in terminal output. (Colorize)
README
# chalk-animation
[![Build Status](https://flat.badgen.net/github/checks/bokub/chalk-animation?label=tests)](https://github.com/bokub/chalk-animation/actions/workflows/run.yml)
[![Version](https://runkit.io/bokub/npm-version/branches/master/chalk-animation?style=flat)](https://www.npmjs.com/package/chalk-animation)
[![Codecov](https://flat.badgen.net/codecov/c/github/bokub/chalk-animation)](https://codecov.io/gh/bokub/chalk-animation)
[![Downloads](https://flat.badgen.net/npm/dm/chalk-animation?color=FF9800)](https://www.npmjs.com/package/chalk-animation)
[![XO code style](https://flat.badgen.net/badge/code%20style/XO/5ed9c7)](https://github.com/sindresorhus/xo)> Colorful animations in terminal output
## Available animations
| Name | Preview |
|:---------:|:------------------------------------------:|
| rainbow | ![rainbow](http://i.imgur.com/napdxdn.gif) |
| pulse | ![pulse](http://i.imgur.com/xdaETwr.gif) |
| glitch | ![glitch](http://i.imgur.com/834FJU1.gif) |
| radar | ![radar](http://i.imgur.com/3bFrtRc.gif) |
| neon | ![neon](http://i.imgur.com/YdAAroI.gif) |
| karaoke | ![karaoke](https://i.imgur.com/lG7EF1t.gif)|## Install
```bash
$ npm i chalk-animation
```## Usage
```javascript
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**.
```javascript
const rainbow = chalkAnimation.rainbow('Lorem ipsum'); // Animation startssetTimeout(() => {
rainbow.stop(); // Animation stops
}, 1000);setTimeout(() => {
rainbow.start(); // Animation resumes
}, 2000);```
#### Automatic stop
Anything printed to the console will stop the previous animation automatically
```javascript
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.
```javascript
chalkAnimation.rainbow('Lorem ipsum', 2); // Two times faster than default
```#### Changing text
Change the animated text seamlessly with `replace()`
```javascript
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()`
```javascript
const rainbow = chalkAnimation.rainbow('Lorem ipsum').stop(); // Don't start the animationrainbow.render(); // Display the first frame
const frame = rainbow.frame(); // Get the second frame
console.log(frame);
```## CLI mode
```bash
# Install package globally
$ npm install --global chalk-animation
``````
$ chalk-animation --helpColorful animations in terminal output
Usage
$ chalk-animation [options] [text...]Options
--duration Duration of the animation in ms, defaults to Infinity
--speed Animation speed as number > 0, defaults to 1Available animations
rainbow
pulse
glitch
radar
neon
karaokeExample
$ chalk-animation rainbow Hello world!
```## Related
- [gradient-string](https://github.com/bokub/gradient-string) - Output gradients to terminal
- [chalk](https://github.com/chalk/chalk) - Output colored text to terminal## License
MIT © [Boris K](https://github.com/bokub)