Skip to content

Ano-ly/colormatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Colormatcher

A Node.js library for generating color harmonies from one or multiple colors. Supports multiple output formats including HSL, RGB, and HEX.


Features

  • Generate color harmonies:
    • Complementary
    • Analogous
    • Triadic
    • Monochromatic
  • Works with a single color or multiple colors
  • Supports multiple output formats: hsl, rgb, hex
  • Uses the colord library for color parsing and conversion

Installation

Using npm

npm install colormatch

Using yarn

yarn add colormatch

Usage

Import the functions

const { getOneMatch, getMatch } = require('colormatch');

API Reference

getOneMatch(color, format)

Generates color harmonies for a single color.

Parameters

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'

Returns

{
  complementary: string[],
  analogous: string[],
  triadic: string[],
  monochromatic: string[]
}

Example

const result = getOneMatch("#3498db", "hex");

console.log(result);

Sample Output

{
  complementary: ["#db6834"],
  analogous: ["#34db98", "#9834db"],
  triadic: ["#98db34", "#db3498"],
  monochromatic: ["#5dade2", "#2e86c1"]
}

getMatch(colors, format)

Generates color harmonies for multiple colors and combines the results.

Parameters

Name Type Description
colors string[] Array of valid color strings
format string Output format: 'hsl', 'rgb', or 'hex'

Returns

{
  complementary: string[],
  analogous: string[],
  triadic: string[],
  monochromatic: string[]
}

Example

const result = getMatch(["#3498db", "red"], "rgb");

console.log(result);

Error Handling

The library throws errors in the following cases:

  • Invalid color input
  • Unsupported format (must be 'hsl', 'rgb', or 'hex')
  • getMatch receives a non-array argument

Dependencies


📄 License

ISC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors