1.0.2 • Published 1 year ago
js-color-converter v1.0.2
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
Name | Description |
---|---|
isHex | Checks that the string is a valid HEX color |
isHsl | Checks that the string is a valid HSL color |
isCmyk | Checks that the string is a valid CMYK color |
isRgb | Checks that the string is a valid RGB color |
getRgbNumbers | Get the array of numbers from the RGB string |
getHslNumbers | Get the array of numbers from the HSL string |
getCmykNumbers | Get the array of numbers from the CMYK string |
convertRgbToCmyk | Convert color format from RGB to CMYK |
convertCmykToRgb | Convert color format from CMYK to RGB |
convertRgbToHsl | Convert color format from RGB to HSL |
convertHslToRgb | Convert color format from HSL to RGB |
convertRgbToHex | Convert color format from RGB to HEX |
convertHexToRgb | Convert color format from HEX to RGB |
getColorsBetweenTwoRgbColors | Get as many RGB colors as you want between the two colors |