1.0.2 • Published 1 year ago

js-color-converter v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

js-color-converter

Utility functions to convert colors.

Install

npm install js-color-converter

Usage

import {
  isHex,
  convertHexToRgb,
  getRgbNumbers,
  getColorsBetweenTwoRgbColors,
} from "js-color-converter";

isHex("#ccc"); // true

convertHexToRgb("#ccc"); // rgb(204, 204, 204)

getRgbNumbers("rgb(204, 204, 204)"); // [204, 204, 204]

getColorsBetweenTwoRgbColors("rgb(255, 0, 0)", "rgb(0, 128, 0)", 2); // ['rgb(255, 0, 0)', 'rgb(170, 43, 0)', 'rgb(85, 85, 0)', 'rgb(0, 128, 0)']

// ...

API

NameDescription
isHexChecks that the string is a valid HEX color
isHslChecks that the string is a valid HSL color
isCmykChecks that the string is a valid CMYK color
isRgbChecks that the string is a valid RGB color
getRgbNumbersGet the array of numbers from the RGB string
getHslNumbersGet the array of numbers from the HSL string
getCmykNumbersGet the array of numbers from the CMYK string
convertRgbToCmykConvert color format from RGB to CMYK
convertCmykToRgbConvert color format from CMYK to RGB
convertRgbToHslConvert color format from RGB to HSL
convertHslToRgbConvert color format from HSL to RGB
convertRgbToHexConvert color format from RGB to HEX
convertHexToRgbConvert color format from HEX to RGB
getColorsBetweenTwoRgbColorsGet as many RGB colors as you want between the two colors