1.1.1 • Published 7 years ago
random-color-js v1.1.1
RandomColor
Module with API that allows you to generate colors and create your own script using the built functions.
Version
1.1.1
Installation
npm
npm install random-color-js
Github
You can also download files from github.
Usage
On production use files only from dist/ folder
Include script
<script src="randomColor.min.js"></script>
API
Example
You can access to the module function by write randomColor.function()
or rc.function()
// Generate random RGB color -> rgb(x, y, z)
var rgb = randomColor.rgb();
// Generate random Hex color -> #xxyyzz
var hex = randomColor.hex();
// Convert the rgb color to Hex color -> #xxyyzz
var convert = randomColor.rgbToHex(rgb);
// Change background-color in the given elements
randomColor.setColor(['tag', '#id', '.class'], rgb, 'background-color');
Options
Function | Type of parameters | Description |
---|---|---|
.rgb() | none | Returns the RGB color |
.hex() | none | Returns the Hex color |
.rgbToHex(color) | string | Convert the rgb color to Hex color |
.setColor(elements, color, style) | object, string, string | Change the color of the element |
.showCode(color, element) | string, string | Show color code in the element |