@kazesolo/text-animation
v1.0.4
Published
Colorful animations in terminal output
Downloads
30
Readme
text-animation
Install
$ npm i @kazesolo/text-animation
Available animations
rainbow
pulse
glitch
radar
neon
karaoke
Usage
Rainbow
const textAnimation = require('@kazesolo/text-animation');
textAnimation.rainbow('Subscribe channel KazeDevID');
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('Subscribe channel'); // 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('Subscribe channel');
setTimeout(() => {
// Stop the 'Subscribe channel' animation, then write on a new line.
console.log('KazeDevID');
}, 1000);
Changing speed
Change the animation speed using a second parameter. Should be greater than 0, default is 1.
chalkAnimation.rainbow('Subscribe channel', 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('Subscribe channel').stop(); // Don't start the animation
rainbow.render(); // Display the first frame
const frame = rainbow.frame(); // Get the second frame
console.log(frame);
Related
- gradient-string - Output gradients to terminal
- chalk - Output colored text to terminal
License
MIT © Kaze