包详细信息

@csstools/convert-colors

jonathantneal6.4mCC0-1.02.0.0

Convert colors between RGB, HEX, HSL, HWB, LAB, LCH, and more

colors, contrast, conversions, converting

自述文件

Convert Colors Convert Colors

NPM Version Linux Build Status Windows Build Status

Convert Colors converts colors between RGB, HEX, HSL, HWB, LAB, LCH, and more.

import convert from '@csstools/convert-colors';

convert.rgb2hsl(100, 100, 100); // [ 0, 0, 100 ]
convert.rgb2hwb(100, 100, 100); // [ 0, 100, 0 ]

convert.hsl2rgb(0, 0, 100); // [ 0, 100, 0 ]
convert.hsl2hwb(0, 0, 100); // [ 0, 100, 0 ]

convert.hwb2rgb(0, 100, 0); // [ 0, 0, 100 ]
convert.hwb2hsl(0, 100, 0); // [ 0, 0, 100 ]

convert.rgb2hue(0, 0, 100); // 240

convert.rgb2contrast([100, 100, 100], [0, 0, 0]); // 21
convert.rgb2ciede2000([100, 100, 100], [0, 0, 0]); // 100

Usage

Add Convert Colors to your build tool:

npm install @csstools/convert-colors --save-dev

Features

Conversions work by taking arguments that represents a color in one color space and returning an array of that same color in another color space.

Documentation

更新日志

Changes to Convert Colors

2.0.0 (January 25, 2019)

  • Add hex, keyword, luminance, contrast, and CIEDE2000 conversions
  • Support Node 6+

1.4.0 (January 27, 2018)

  • Add LCH conversions
  • Allow fallbacks in RGB conversions (for gray conversions)
  • Add Lab and LCH tests
  • Simplify test array joining
  • Rename references from "LAB" to "Lab"

1.3.0 (January 25, 2018)

  • Export all converter combinations of rgb, hsl, hwb, lab, hsv, xyz, and also the rgb2hue converter
  • Organize library into files

1.2.0 (January 24, 2018)

  • Export rgb2lab, lab2rgb, hsl2lab, etc. converters

1.1.0 (January 22, 2018)

  • Export rgb2hue converter

1.0.0 (January 21, 2018)

  • Initial version