Socket
Book a DemoInstallSign in
Socket

consistent-color-generation

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consistent-color-generation

This package generates colors given a string according to XEP-0392 0.6

0.4.0
latest
Source
npmnpm
Version published
Weekly downloads
39
160%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status codecov npm version

Consistent Color Generation

This node script generates colors given a string according to XEP-0392 0.6.

Features

Implemented

  • RGB color generation
  • Red/Blue-blindness correction
  • Blue-blindness correction

Not yet implemented

  • Adapting colors for a specific background color
  • Mapping to a color palette

How to use

Install all dependencies with yarn install and import the script as usual:

var getRGB = require('./consistent-color-generation');

Generate color without Color Vision Deficiency correction:

var color = getRGB('Foobar');
// color.r, color.g, color.b

Get css color string:

color.toString()      // rgb(0, 0, 0)
color.toString('hex') // #000000

Generate color with Red/Green-blindness correction:

var color = getRGB('Foobar', 'redgreen');

Generate color with Blue-blindness correction:

var color = getRGB('Foobar', 'blue');

You can also adjust the saturation and lightness:

var color = getRGB('Foobar', undefined, 80, 30);

Development

Install all dependencies with yarn install and run yarn test before every commit.

FAQs

Package last updated on 11 May 2020

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.