colour-swapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Colour Swapper

JavaScript color swaping

colour-swapper is a compact and efficient JavaScript library designed for color manipulation and conversion, leveraging the capabilities of tinycolor2.

This library simplifies the process of converting RGB colors to their grayscale equivalents, allowing developers to easily transform individual colors or entire color palettes to their grayscale versions.

Additionally, colour-swapper offers functionality to find the closest color value within a given palette, providing a convenient solution for color matching and palette optimization.

Uasge

  npm install colour-swapper
  1. Convert RBG to Graytone

    import { grayscale } from 'colour-swapper';
    
    const inputColor = '#008000';
    const result = grayscale(inputColor);
    console.log(result)
  2. Swap RBG colors based on given colors

    import { colorswap } from 'colour-swapper';
    
    const colorPallet = ['#fc5185','#364f6b','#43dde6','#f0f0f0'];
    const inputColors = ['#ffff00' ,'#ffa500'];
    const result = colorswap(inputColors, colorPallet);
    console.log(result)

Package Sidebar

Install

npm i colour-swapper

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

45.8 kB

Total Files

12

Last publish

Collaborators

  • umanda