Coder Social home page Coder Social logo

hougesen / generate-random-color Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 1.09 MB

NPM package for generating random HEX, RGB, RGBA, HSL and HSLA colors.

Home Page: https://www.npmjs.com/package/generate-random-color

License: MIT License

TypeScript 100.00%
random-generation color npm-package random random-color random-color-generator generator rgb hex hsl

generate-random-color's Introduction

generate-random-color

NPM package for generating random HEX, RGB, RGBA, HSL and HSLA colors.

Install

npm install generate-random-color

Usage

const generateRandomColor = require('generate-random-color');
// or
import generateRandomColor from 'generate-random-color';

// The function can either be called by simply calling the function like this
generateRandomColor.hex();
generateRandomColor.rgb();
generateRandomColor.rgba();
generateRandomColor.hsl();
generateRandomColor.hsla();

// or by passing optional min max values.
generateRandomColor.rgb({
  r: { min: 0, max: 255 },
  g: { min: 0, max: 255 },
  b: { min: 0, max: 255 },
});

// Omitted values will default to the min & max value of the color type.
generateRandomColor.rgb({
  g: { min: 100 },
  b: { min: 0, max: 100 },
});

// HEX can be passed a specific value. If no input is given the value will be between 00 - FF
// Returns #FF69B4
generateRandomColor.hex({
  r: 'ff',
  g: '69',
  b: 'b4',
});

// RGBA default values
generateRandomColor.rgba({
  r: { min: 0, max: 255 },
  g: { min: 0, max: 255 },
  b: { min: 0, max: 255 },
  a: { min: 0, max: 1 },
});

// HSL default values
generateRandomColor.hsl({
  h: { min: 0, max: 360 },
  s: { min: 0, max: 100 },
  l: { min: 0, max: 100 },
});

// HSLA default values
generateRandomColor.hsla({
  h: { min: 0, max: 360 },
  s: { min: 0, max: 100 },
  l: { min: 0, max: 100 },
  a: { min: 0, max: 1 },
});

generate-random-color's People

Contributors

dependabot[bot] avatar hougesen avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

arangconjeeko

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.