Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hougesen/generate-random-color
NPM package for generating random HEX, RGB, RGBA, HSL and HSLA colors.
https://github.com/hougesen/generate-random-color
color generator hex hsl npm-package random random-color random-color-generator random-generation rgb
Last synced: 3 months ago
JSON representation
NPM package for generating random HEX, RGB, RGBA, HSL and HSLA colors.
- Host: GitHub
- URL: https://github.com/hougesen/generate-random-color
- Owner: hougesen
- License: mit
- Created: 2021-06-27T16:55:55.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T00:28:59.000Z (6 months ago)
- Last Synced: 2024-08-09T09:28:06.459Z (5 months ago)
- Topics: color, generator, hex, hsl, npm-package, random, random-color, random-color-generator, random-generation, rgb
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/generate-random-color
- Size: 1.07 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# generate-random-color
NPM package for generating random HEX, RGB, RGBA, HSL and HSLA colors.
## Install
```bash
npm install generate-random-color
```## Usage
```js
const generateRandomColor = require('generate-random-color');
// or
import generateRandomColor from 'generate-random-color';// The function can either be called by simply calling the function like this
generateRandomColor.hex();
generateRandomColor.rgb();
generateRandomColor.rgba();
generateRandomColor.hsl();
generateRandomColor.hsla();// or by passing optional min max values.
generateRandomColor.rgb({
r: { min: 0, max: 255 },
g: { min: 0, max: 255 },
b: { min: 0, max: 255 },
});// Omitted values will default to the min & max value of the color type.
generateRandomColor.rgb({
g: { min: 100 },
b: { min: 0, max: 100 },
});// HEX can be passed a specific value. If no input is given the value will be between 00 - FF
// Returns #FF69B4
generateRandomColor.hex({
r: 'ff',
g: '69',
b: 'b4',
});// RGBA default values
generateRandomColor.rgba({
r: { min: 0, max: 255 },
g: { min: 0, max: 255 },
b: { min: 0, max: 255 },
a: { min: 0, max: 1 },
});// HSL default values
generateRandomColor.hsl({
h: { min: 0, max: 360 },
s: { min: 0, max: 100 },
l: { min: 0, max: 100 },
});// HSLA default values
generateRandomColor.hsla({
h: { min: 0, max: 360 },
s: { min: 0, max: 100 },
l: { min: 0, max: 100 },
a: { min: 0, max: 1 },
});
```