Skip to content

Generate a random rgba color string, using an optional opacity (alpha) value.

Notifications You must be signed in to change notification settings

fauteuil/random-rgba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Random rgba

Generate a random rgba string value in Javascript (ES6)

Installation

npm install random-rgba --save

or

yarn add random-rgba


Syntax

randomRgba(alpha);

Parameters

  • alpha: Optional integer alpha value. This defaults to a random alpha value between .1 and 1.

Return value

  • randomRgba will return a randomly generated rgba string value with the optionally supplied alpha value, or will generate a random alpha if none is supplied.

Usage

Import the randomRgba function

import randomRgba from "random-rgba";

or

const randomRgba = require("random-rgba")

Sample implementations

// Returns a random rgba string value with an alpha of ".47".
const myRandomRgba = randomRgba(47); // Outputs something like "rgba(34,126,218,.47)"

// Returns a random rgba string value with a random alpha value.
const myRandomRgba = randomRgba();

About

Generate a random rgba color string, using an optional opacity (alpha) value.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published