@kazesolo/text-animation

1.0.4 • Public • Published

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

License

MIT © Kaze

Package Sidebar

Install

npm i @kazesolo/text-animation

Weekly Downloads

15

Version

1.0.4

License

MIT

Unpacked Size

55 kB

Total Files

17

Last publish

Collaborators

  • kazedevid