npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

random-color-array-generator

v1.0.3

Published

Generate Random Colors Array in RGB, HEX, HSL, RGBA, HSLA and also provide inbuilt class for creating button

Downloads

137

Readme

Random Color Array Generator

This package enables you to generate random colors array of desired length in different forms (RGB,RGBA,HEX,HSL,HSLA).

Additional Components

This package also provides CSS classes for creating button

Usage

npm i random-color-array-generator

CDN

JSDELIVR

https://cdn.jsdelivr.net/npm/[email protected]/ColorGeneratorCDN.min.js
https://cdn.jsdelivr.net/npm/[email protected]/Button.min.css

UNPKG

https://unpkg.com/[email protected]/ColorGeneratorCDN.min.js
https://unpkg.com/[email protected]/Button.min.js

CDN Usage

<script src="https://cdn.jsdelivr.net/npm/[email protected]/ColorGeneratorCDN.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/Button.min.css"></script>

Structure

•
└── randomArrayColorGenerator
    ├── ColorGenerator.min.js
    ├── ColorGenerator.js
    ├── Conversions.min.js
    ├── Conversions.js
    ├── ColorGeneratorCDN.js
    ├── ColorGeneratorCDN.min.js
    ├── Button.css
    ├── Button.min.css
    └── README.md

Usage

import ColorGenerator from "random-color-array-generator/ColorGenerator.min.js";
const colorGenerator = new ColorGenerator(sizeOfArray);
// Here in place of sizeOfArray provide length of array you want like 5
console.log(colorGenerator.generateRGB());
// ['rgb(67,154,213)','rgb(177,96,168)','rgb(230,115,4)','rgb(159,93,46)','rgb(113,177,166)']
console.log(colorGenerator.generateHEX());
// [ '#8f0e63', '#5caf51', '#46e331', '#e6d0d3', '#13b8ab' ]
console.log(colorGenerator.generateHSL());
// ['hsl(295,62.5%,52.9%)','hsl(40,53.9%,29.8%)','hsl(88,67%,34.5%)','hsl(322,79.5%,49.8%)','hsl(90,37.6%,66.7%)']
console.log(colorGenerator.generateHSV());
// ['176, 96, 77','63, 71, 61','74, 62, 86','60, 37, 95','232, 81, 98']
console.log(colorGenerator.generateRGBA());
// ['rgba(21,74,146,0.73)','rgba(107,250,202,0.30)','rgba(241,34,163,0.55)','rgba(114,95,192,0.52)','rgba(213,96,0,0.56)']
console.log(colorGenerator.generateHSLA());
// ['hsla(7, 41.7%, 70.4%, 0.89)','hsla(314, 97.1%, 41%, 0.73)','hsla(115, 75.2%, 42.7%, 0.79)','hsla(145, 47.4%, 41%, 0.36)','hsla(75, 65.4%, 40.8%, 0.46)']

Available Functions

| Function Name | Description | Example Outputs | | :-------------------- | :------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- | | getCurrentSizeOfArray | Return current value which is set for array length | 5 | | setSizeOfArray | Setter for changing value of array length | | | generateRGB | Return array of random rgb values | ['rgb(67,154,213)','rgb(177,96,168)','rgb(230,115,4)','rgb(159,93,46)','rgb(113,177,166)'] | | generateHEX | Return array of random hex values | [ '#8f0e63', '#5caf51', '#46e331', '#e6d0d3', '#13b8ab' ] | | generateHSL | Return array of random hsl values | ['hsl(295,62.5%,52.9%)','hsl(40,53.9%,29.8%)','hsl(88,67%,34.5%)','hsl(322,79.5%,49.8%)','hsl(90,37.6%,66.7%)'] | | generateHSV | Return array of random hsv values | ['176, 96, 77','63, 71, 61','74, 62, 86','60, 37, 95','232, 81, 98'] | | generateRGBA | Return array of random rgba values | ['rgba(21,74,146,0.73)','rgba(107,250,202,0.30)','rgba(241,34,163,0.55)','rgba(114,95,192,0.52)','rgba(213,96,0,0.56)'] | | generateHSLA | Return array of random hsla values | ['hsla(7, 41.7%, 70.4%, 0.89)','hsla(314, 97.1%, 41%, 0.73)','hsla(115, 75.2%, 42.7%, 0.79)','hsla(145, 47.4%, 41%, 0.36)','hsla(75, 65.4%, 40.8%, 0.46)'] |

Tutorial

Link To Tutorial

Available CSS Classes

| Class Name | Functioning | | :--------------------- | :----------------------------------- | | custom-generate-button | Generate Base For Button | | button-purple | Provides purple background to button | | button-teal | Provides teal background to button | | button-blue | Provides blue background to button | | button-red | Provides red background to button | | button-yellow | Provides yellow background to button | | button-pink | Provides pink background to button |

Button Example

<!-- Import StyleSheet -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/ColorGeneratorCDN.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/Button.min.css"></script>
<script>
    const colorGenerator  = new ColorGenerator(5)
    console.log(colorGenerator.generateHEX()) //["#762775", "#f7f7c5", "#9f4cfa", "#94726d", "#2db4af"]
</script>
<button class="custom-generate-button button-pink" id="generate-color">This is custom generate button</button>