1.0.4 • Published 2 years ago
@miroyar/ccolor v1.0.4
cColor pre-alpha(!)
Utility for console text color. Based on 3-bit, 4-bit color chart from Wikipedia.
Description
Method: cColor \ Type:
(text: string, initial: StringColorInitial | ObjectColorInitial) => string;Type: StringColorInitial \ Description: Has a value from the table of color full initials.
Type: ObjectColorInitial
{
F?: ColorInitials;
B?: ColorInitials;
}Description: An object consisting of two keys F and B, denoting the position of the Foreground and Background colors and having a value from the color initials table.
Table: Colored initials that you can see here.
| Color | Foreground | Background |
|---|---|---|
| F+ | B+ | |
| Black | D | |
| Red | R | |
| Green | G | |
| Yellow | Y | |
| Blue | B | |
| Magenta | M | |
| Cyan | C | |
| White | W | |
| Bright Black (Gray) | BD | |
| Bright Red | BR | |
| Bright Green | BG | |
| Bright Yellow | BY | |
| Bright Blue | BB | |
| Bright Magenta | BM | |
| Bright Cyan | BC | |
| Bright White | BW |
Example:
import { CColor } from '@miroyar/ccolor';
const text = 'The SGR parameters 30–37 selected the foreground color, while 40–47 selected the background.';
const cColor = new CColor();
console.log(cColor.print(text, 'FB'));
console.log(cColor.print(text, 'BBG'));
console.log(cColor.print(text, { F: 'B', B: 'BG' }));