https://github.com/jsxc/consistent-color-generation
This package generates colors given a string according to XEP-0392
https://github.com/jsxc/consistent-color-generation
Last synced: 8 months ago
JSON representation
This package generates colors given a string according to XEP-0392
- Host: GitHub
- URL: https://github.com/jsxc/consistent-color-generation
- Owner: jsxc
- License: mit
- Created: 2017-11-21T09:47:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T19:23:20.000Z (almost 4 years ago)
- Last Synced: 2025-10-07T07:32:10.811Z (8 months ago)
- Language: JavaScript
- Size: 206 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/jsxc/consistent-color-generation)
[](https://codecov.io/gh/jsxc/consistent-color-generation)
[](https://www.npmjs.com/package/consistent-color-generation)
# Consistent Color Generation
This node script generates colors given a string according to [XEP-0392 0.6](https://xmpp.org/extensions/xep-0392.html#constants-ycbcr).
## 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.