Socket
Socket
Sign inDemoInstall

@colorblender/converter-name

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @colorblender/converter-name

Convert RGB to Name and vice versa.


Version published
Maintainers
1
Created

Readme

Source

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.

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

Keywords

FAQs

Last updated on 04 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc