1.0.1 • Published 2 months ago

@colorblender/converter-name v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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.

// name to rgb
nameToRgb(name: NameColor, rounded?: boolean): RgbColor

// rgb to name
rgbToName(rgb: RgbColor): NameColor

Example

import { rgbToName, nameToRgb } from '@colorblender/converter-name';

rgbToName({
  r: 255,
  g: 255,
  b: 255,
});

// Rounded
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

  • NAME: string

Issues

Please file an issue for bugs, missing documentation, or unexpected behavior.

File an issue

License

MIT