A library for generating random color sets consisting of a background color and a visible text color based on that background color.
npm install random-color-set
const {generateRandomColorSet} = require('random-color-set')
const colorSet = generateRandomColorSet()
console.log(colorSet)
// { backgroundColor: '#c77d0e', textColor: '#FFFFFF' }
import {generateRandomColorSet} from 'random-color-set'
const colorSet = generateRandomColorSet()
console.log(colorSet)
// { backgroundColor: '#1dc660', textColor: '#FFFFFF' }
Generates a random color set consisting of a background color and a visible text color based on that background color.
- ColorSet: An object with
backgroundColor
andtextColor
properties.
Generates a color set consisting of a background color and a visible text color based on that background color.
backgroundColor (string): The background color code to use.
- ColorSet: An object with
backgroundColor
andtextColor
properties.
Generates a random color code in the format "#RRGGBB".
- string: A random color code.
Extracts RGB values from a color code string in the format "#RRGGBB".
- colorCode (string): The color code string to extract RGB values from.
- RGBColor: An object with
r
,g
, andb
properties representing the red, green, and blue values.
Calculates the luminance of an RGB color.
- r (number): The red value of the color (0-255).
- g (number): The green value of the color (0-255).
- b (number): The blue value of the color (0-255).
- number: The luminance of the color (0-1).
MIT