Tintify is an NPM package that brings you all you need to add colors and effects to your terminal!
This package isn't a simple list of ANSI escape sequences.
It brings you utilities functions that permit you to use custom RGB colors or the HEXADECIMAL notations.
In future update, we will bring you others functions like new formatters. Current formatters permit you to transform your message into an rainbow text, a linear gradient between two colors, a matrix style text or a format function where you can pass flags to replace with a color (ie: flag §3
or §b
will be transformed to a color or effect according to the config)
Installation
npm install tintify
OR
pnpm install tintify
Updates
Want to see new content? Open an issue!
Overview
Basic usage
Usage of constants
import { forground, brightBackground } from "tintify";
console.log(`${forground.blue}Hello ${forground.red}${brightBackground.blue}World!`);
Usage of functions
import { forgroundRGBColor, backgroundRGBColor, hexToRgb } from "tintify";
const helloFgColor = forgroundRGBColor({red: 63, green: 112, blue: 84});
const worldFgColor = forgroundRGBColor(hexToRgb("#9d19c2"));
const worldBgColor = backgroundRGBColor({red: 63, green: 112, blue: 84});
console.log(`${helloFgColor}Hello ${worldFgColor}${worldBgColor}World!`);
Formatters usage
Linear gradient effect
import { hexToRgb, linearGradient } from "tintify";
console.log(linearGradient("Tintify tints your untinted terminal", hexToRgb("#40db21"), {red: 255, green: 0, blue: 0}));
Matrix effect
import { hexToRgb, matrix } from "tintify";
console.log(matrix("Tintify tints your untinted terminal", hexToRgb("#00FF00")));
console.log(matrix("Tintify tints your untinted terminal", hexToRgb("#00FF00"), 200));
Rainbow effect
import { hexToRgb, rainbow } from "tintify";
console.log(rainbow("Tintify tints your untinted terminal"));
console.log(rainbow("Tintify tints your untinted terminal", hexToRgb("#00FF00")));
console.log(rainbow("Tintify tints your untinted terminal", hexToRgb("#00FF00"), 100));
console.log(rainbow("Tintify tints your untinted terminal", hexToRgb("#00FF00"), 100, false));
Format
import { defaultFormatConfig, forground, format } from "tintify";
console.log(format("§2Hello §b§4World!"));
console.log(format("§2Hello §b§4World!", {
...defaultFormatConfig,
"§2": forground.blue
}));
Top comments (3)
Amazing work, nice to use!
what is the difference between chalk and this package?
Chalk 5.0.0 is ESM, while this one supports ESM as well as CJS. So most people can use it without problems.
To continue, if you want create a message like this:
You will have to write with Chalk:
The reading can become very quickly laborious just because:
If we compare to Tintify which does not use functions but constants:
Of course, you can use aliases in the imports to shorten the naming if you wish:
So now we have:
effect.bold
in my string. If I want to remove it:effectReset.bold
)In addition, it also brings you formatting functions that allow you to create cool effects like linear gradients, rainbow text, or even simpler formatting where you pass a string like
"§aHello §bWorld!"
which will return yourHello World!
in green with theWorld!
in bold depending on the flags you choose! (return equivalent to${forground.green}Hello ${effect.bold}World!
)Otherwise Tintify also brings you utility functions like conversion of hexadecimal values to RGB, or validators of RGB/hex values.