@utilify/colors v1.0.1
Color Utilities
The color utility functions provide a variety of methods for color conversion and validation operations. These functions help simplify common tasks, such as converting between different color formats and validating color strings.
Installation
To install the color utility functions, use one of the following commands, depending on your package manager:
npm install @utilify/colorsyarn add @utilify/colorspnpm add @utilify/colorsAfter installation, you can import the functions into your project using either ESM or CJS.
Usage
This library supports both the ESM and CJS module systems.
import { rgbToHsl, rgbToHex, isRgb } from '@utilify/colors';const { rgbToHsl, rgbToHex, isRgb } = require('@utilify/colors');Overview
Here is an overview of the functions available in the color utilities package:
rgbToHsl
function rgbToHsl(rgb: string): string | nullConverts an RGB color string to its HSL representation.
rgbToHex
function rgbToHex(rgb: string): string | nullConverts an RGB color string to its hexadecimal representation.
isRgb
function isRgb(rgb: string): booleanChecks if a given string is a valid RGB or RGBA color.
isHsl
function isHsl(hsl: string): booleanChecks if a given string is a valid HSL or HSLA color.
isHex
function isHex(hex: string): booleanChecks if a given string is a valid hexadecimal color, including the alpha channel.
hslToRgb
function hslToRgb(hsl: string): string | nullConverts an HSL color string to its RGB representation.
hslToHex
function hslToHex(hsl: string): string | nullConverts an HSL color string to its hexadecimal representation.
hexToRgb
function hexToRgb(hex: string): string | nullConverts a hexadecimal color string to its RGB representation.
hexToHsl
function hexToHsl(hex: string): string | nullConverts a hexadecimal color string to its HSL representation.