@chriscodesthings/random-rgb-color
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

random-rgb-color
Test workflow status NPM Version License: MIT

Generates a random color in RGB format

Description

Generates a random color in RGB format and returned as an array.

See...


Install

npm install --save @chriscodesthings/random-rgb-color

Usage

import randomRGBColor from '@chriscodesthings/random-rgb-color';

console.log(randomRGBColor());
// => [78, 143, 28]

Types

This package uses types from:

Syntax

randomRGBColor((tone));

Parameters

  • tone (optional): If true, colour is dark, if false, colour is light, based on YIQ calculation.

Return Value

Returns an array containing red, green and blue values from 0 to 255.

Examples

// random colour that should look ok with black text
function pickBackgroundColour() {
    return randomRGBColor(false);
} 

See Also...

Readme

Keywords

Package Sidebar

Install

npm i @chriscodesthings/random-rgb-color

Weekly Downloads

56

Version

1.0.1

License

MIT

Unpacked Size

6.96 kB

Total Files

8

Last publish

Collaborators

  • chriscodesthings