2.2.0 • Published 9 months ago

@mattbrannon/convert v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@mattbrannon/convert

This is a collection of functions for converting one thing to another. Currently those things are colors and angles. Color formats currently include:

  • rgb
  • hsl
  • hex
  • hsv
  • hwb
  • cmyk
  • lch

Angle formats currently include:

  • degree
  • radian
  • gradian
  • turn

Installation

This package is available on Npm. You can install it using the package manager of your choice.

npm i --save @mattbrannon/convert

This package is compatible with both ESM (ES Modules) and CJS (Common JS).

Usage

Color conversion functions can be called in one of two ways.

  • Pass an array of values representing the individual color channels
  • Pass each color channel individually as an argument.

The exception to the rule is for hexadecimal conversions which always require a string

import { rgb, hex } from '@mattbrannon/convert';

// these are functionally equivalent to each other

rgb.lch([255, 0, 255]); // array of values
rgb.lch(255, 0, 255); // individual values

hex.hsl('#ff00ff');
2.2.0

9 months ago

2.1.0

10 months ago

2.0.1

10 months ago

2.0.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago