A Node.js library for generating color harmonies from one or multiple colors. Supports multiple output formats including HSL, RGB, and HEX.
- Generate color harmonies:
- Complementary
- Analogous
- Triadic
- Monochromatic
- Works with a single color or multiple colors
- Supports multiple output formats:
hsl,rgb,hex - Uses the
colordlibrary for color parsing and conversion
npm install colormatchyarn add colormatchconst { getOneMatch, getMatch } = require('colormatch');Generates color harmonies for a single color.
| Name | Type | Description |
|---|---|---|
| color | string | Any valid color string ("#ff0000", "red", "rgb(255,0,0)", "hsl(0, 100%, 50%)") |
| format | string | Output format: 'hsl', 'rgb', or 'hex' |
{
complementary: string[],
analogous: string[],
triadic: string[],
monochromatic: string[]
}const result = getOneMatch("#3498db", "hex");
console.log(result);Sample Output
{
complementary: ["#db6834"],
analogous: ["#34db98", "#9834db"],
triadic: ["#98db34", "#db3498"],
monochromatic: ["#5dade2", "#2e86c1"]
}Generates color harmonies for multiple colors and combines the results.
| Name | Type | Description |
|---|---|---|
| colors | string[] | Array of valid color strings |
| format | string | Output format: 'hsl', 'rgb', or 'hex' |
{
complementary: string[],
analogous: string[],
triadic: string[],
monochromatic: string[]
}const result = getMatch(["#3498db", "red"], "rgb");
console.log(result);The library throws errors in the following cases:
- Invalid color input
- Unsupported format (must be
'hsl','rgb', or'hex') getMatchreceives a non-array argument
ISC