Converter Name
Convert RGB to Name and vice versa.
Installation
This package requires the installation of the main package @colorblender/converter
.
npm install @colorblender/converter @colorblender/converter-name
Import
import { rgbToName, nameToRgb } from '@colorblender/converter-name';
Usage
Model conversions
You can convert between any of the supported color models.
nameToRgb(name: NameColor, rounded?: boolean): RgbColor
rgbToName(rgb: RgbColor): NameColor
Example
import { rgbToName, nameToRgb } from '@colorblender/converter-name';
rgbToName({
r: 255,
g: 255,
b: 255,
});
nameToRgb('White', true);
Conversion
You can convert any compatible model to RGB format and vice versa.
To convert two compatible and different RGB models you will have to go through a sub-conversion. For example to convert a HEX value to NAME you will have to do: HEX -> RGB -> NAME. This allows you to convert any compatible model to any other.
Keep in mind that large conversions may result in a loss of accuracy.
Supported color models
Issues
Please file an issue for bugs, missing documentation, or unexpected behavior.
File an issue
License
MIT