API Reference
API reference for the library
convertColor
Function | pigment.convertCOlor(color: string, format: Format, prefix?: string) : string |
---|---|
Description | Converts a color from one format to another. |
Parameters | color (string): The color value (e.g., '#ff5733' ).format (Format): See all the supported formats prefix (string): Adds a tailwind prefix (e.g., bg-red-500 ) |
Returns | A string value of the converted color. |
Note
While converting hex to tailwind, use uppercase hex code. Support for lowecase will be added soon
lightenColor
Function | pigment.lightenColor(color: string, percent: number) : string |
---|---|
Description | Lightens a color by a specified percentage. |
Parameters | color (string): The color value (e.g., '#ff5733' ).percent (number): Percentage to lighten (e.g., 0.3 ) |
Returns | A string value of the lightend color. |
darkenColor
Function | pigment.darkenColor(color: string, percent: number) : string |
---|---|
Description | Darkens a color by a specified percentage. |
Parameters | color (string): The color value (e.g., '#ff5733' ).percent (number): Percentage to darken (e.g., 0.3 ) |
Returns | A string value of the darkened color. |
randomColor
Function | pigment.randomColor(format: Format, prefix?: string): string |
---|---|
Description | Generates a random color. |
Parameters | format (Format): See all the supported formats prefix (string): Adds a tailwind prefix (e.g., bg-red-500 ) |
Returns | A string value of the random color. |
toTailwind
Function | pigment.toTailwind(color: string, prefix?: string) : string |
---|---|
Description | Converts a color to Tailwind. |
Parameters | color (string): The color value (e.g., '#ff5733' ).prefix (string): Adds a tailwind prefix (e.g., bg-red-500 ) |
Returns | A string value of the tailwind color. |
Note
Currently only the exact tailwind color will be converted. Support for nearest color will be added soon
setOpacity
Function | pigment.setOpacity(color: string, amount: number, to: Alpha) : string |
---|---|
Description | Sets the opacity of a color. |
Parameters | color (string): The color value (e.g., '#ff5733' ).amount (number): The opacity value (e.g., 0.5 ) to (Alpha): The alpha format (e.g., hsla and rgba ) |
Returns | A string value of the color with opacity. |
blendColors
Function | pigment.blendColors(color1: string, color2: string, ratio: number) : string |
---|---|
Description | Blends two colors together. |
Parameters | color1 (string): The first color value (e.g., '#ff5733' ).color2 (string): The second color value (e.g., '#ff5733' ).ratio (number): The percentage of the blend (e.g., 0.5 ) |
Returns | A string value of the blended color of the format of first color. |
Note
The prefix for Tailwind color will be taken from the first color.