1.0.7 • Published 1 year ago

color-conversion-tools v1.0.7

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

color-conversion-tools

Utility functions to convert colors.

Install

npm install color-conversion-tools

Usage

import {
  isHex,
  convertHexToRgb,
  getRgbNumbers,
  getColorsBetweenRgbColors,
} from "color-conversion-tools";

isHex("#ccc"); // true

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

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

getColorsBetweenRgbColors("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
isHexThis function checks if the given string is a valid HEX color code.
isHslThis function checks if the given string is a valid HSL color code.
isCmykThis function checks if the given string is a valid CMYK color code.
isRgbThis function checks if the given string is a valid RGB color code.
getRgbNumbersThe function will extract the array of numbers from the provided RGB string.
getHslNumbersThe function will extract the array of numbers from the provided HSL string.
getCmykNumbersThe function will extract the array of numbers from the provided CMYK string.
convertRgbToCmykThe function takes RGB and converts it to CMYK.
convertCmykToRgbThe function takes CMYK and converts it to RGB.
convertRgbToHslThe function takes RGB and converts it to HSL.
convertHslToRgbThe function takes HSL and converts it to RGB.
convertRgbToHexThe function takes RGB and converts it to HEX.
convertHexToRgbThe function takes HEX and converts it to RGB.
getColorsBetweenRgbColorsThe function takes two RGB color and generates an array of colors between the two input colors.

Authors

Petros Petrosyan

License

MIT