JSPM

randomizer-pro-js

1.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q37164F
  • License MIT

A JavaScript package to generate random colors and numbers.

Package Exports

  • randomizer-pro-js
  • randomizer-pro-js/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (randomizer-pro-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Randomizer Pro JS

A JavaScript package to generate random colors and numbers.

Installation

You can install randomizer-pro-js via npm:

npm install randomizer-pro-js

Functions

getRandomNumber(min, max)

Generates a random integer between min (inclusive) and max (inclusive).

Parameters:

  • min (number): The minimum value.
  • max (number): The maximum value.

Returns:

  • number: A random integer between min and max.

getRandomFloat(min, max)

Generates a random float between min (inclusive) and max (inclusive)

Parameters:

  • min (number): The minimum value.
  • max (number): The maximum value.

Returns:

  • number: A random float between min and max.

getRandomHexaColor()

Generates a random color in hexadecimal format.

Returns:

  • string: A random color in hexadecimal format (e.g: #ff5733).

getRandomHSL()

Generates a random color in HSL (Hue, Saturation, Lightness) format.

Returns:

  • string: A random color in HSL format (e.g., hsl(120, 100%, 50%)).

getRandomRgbColor()

Generates a random color in RGB (Red, Green, Blue) format.

Returns:

  • string: A random color in RGB format (e.g., rgb(120, 100, 50)).

getRandomRgbaColor()

Generates a random color in RGB with alpha (Red, Green, Blue) format. You can change opacity of your colors.

Returns:

  • string: A random color in RGBa format (e.g., rgb(120, 100, 50,1)).

Usage

Importing the Package

First, import the package into your project:

const { getRandomNumber, getRandomFloat, getRandomRgbaColor, getRandomHSL,getRandomHexaColor , getRandomRgbColor } = require('randomizer-pro-js');

OR

import {getRandomNumber, getRandomFloat, getRandomRgbaColor, getRandomHSL,getRandomHexaColor , getRandomRgbColor} from 'randomizer-pro-js'

Examples

Generating Random Numbers

To generate random numbers, use the getRandomNumber function. Specify the minimum and maximum values as parameters.

const randomInt = getRandomNumber(1, 100);
console.log(randomInt);

Generating Random Floating-Point Numbers

To generate random floating-point numbers, use the getRandomFloat function. Specify the minimum and maximum values as parameters.

const randomFloat = getRandomFloat(1, 100);
console.log(randomFloat); // e.g., 42.567

Generating RGB Colors

To generate random rgb colors, use the getRandomRgbColor function. This function returns a random color in hexadecimal format.

const color = getRandomRgbColor();
console.log(color); // e.g., #ff5733

Generating Random HSL Colors

To generate random HSL colors, use the getRandomHSL function. This function returns a random color in HSL format.

const hslColor = getRandomHSL();
console.log(hslColor); // e.g., hsl(120, 100%, 50%)

Generating RGBa Colors

To generate random rgba colors, use the getRandomRgbaColor function. This function returns a random color in hexadecimal format.

const color = getRandomRgbaColor(1);
console.log(color); // e.g., #ff5733

Contributing

If you would like to contribute, please fork the repository and submit a pull request.

License

This project is licensed under the MIT License.

Author

Bilal Shahid