Converter Ansi
Convert rgb to ansi16 / ansi256 and vice versa.
Installation
This package requires the installation of the main package @colorblender/converter.
npm install @colorblender/converter @colorblender/converter-ansi
Import
import {
rgbToAnsi16,
rgbToAnsi256,
ansi16ToRgb,
ansi256ToRgb,
} from '@colorblender/converter-ansi';
Usage
Model conversions
You can convert between any of the supported color models.
ansi16ToRgb(ansi16: Ansi16Color, rounded?: boolean)
ansi256ToRgb(ansi256: Ansi256Color, rounded?: boolean)
rgbToAnsi16(rgb: RgbColor)
rgbToAnsi256(rgb: RgbColor)
Supported color models
- ANSI16: number
- ANSI256 number
Example
import { rgbToHsl } from '@colorblender/converter';
rgbToAnsi16({
r: 255,
g: 255,
b: 255,
});
ansi16ToRgb(167, true);
Issues
Please file an issue for bugs, missing documentation, or unexpected behavior.
File an issue
License
MIT