https://github.com/randplus/color
A package that adds functions for random.
https://github.com/randplus/color
color hex name nodejs npm package random rgb
Last synced: 5 months ago
JSON representation
A package that adds functions for random.
- Host: GitHub
- URL: https://github.com/randplus/color
- Owner: randplus
- Created: 2024-10-10T04:38:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-01T01:42:57.000Z (10 months ago)
- Last Synced: 2025-10-01T10:54:27.693Z (9 months ago)
- Topics: color, hex, name, nodejs, npm, package, random, rgb
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@randplus/color
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @randplus/color
Generate random colors.
This package is included in '[randplus](https://www.npmjs.com/package/randplus)'.
###### Teams

## Usage
```js
// Classic
const random = require('@randplus/color');
console.log(random('hex')); // '000000' ~ 'ffffff'
console.log(random('hex', { prefix: '#' })); // '#000000' ~ '#ffffff'
console.log(random('rgb')); // [0, 0, 0] ~ [255, 255, 255]
console.log(random('word')); // 'limegreen'
console.log(random('word', { language: 'ja' })); // '鉄色'
```
```js
// Advanced
const { hex, rgb, word } = require('@randplus/color');
console.log(hex()); // '000000' ~ 'ffffff'
console.log(hex('#')); // '#000000' ~ '#ffffff'
console.log(rgb()); // [0, 0, 0] ~ [255, 255, 255]
console.log(word()); // 'limegreen'
console.log(word('cn')); // '紫磨金'
```
### Get Color Name Example:
Install [color-name-lib](https://www.npmjs.com/package/color-name-lib).
```sh
npm i color-name-lib
```
```js
const { hex } = require('@randplus/color');
const colorName = require('color-name-lib');
const colorHex = hex();
const name = colorName(colorHex);
console.log(`${colorHex}: ${name}`);
```
or use `lib/color-name-lib.js`.
```js
const { hex } = require('@randplus/color');
const colorName = require('@randplus/color/lib/color-name-lib');
const colorHex = hex();
const name = colorName(colorHex);
console.log(`${colorHex}: ${name}`);
```