source: trip-planner-front/node_modules/color-convert/README.md

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.8 KB
Line 
1# color-convert
2
3[![Build Status](https://travis-ci.org/Qix-/color-convert.svg?branch=master)](https://travis-ci.org/Qix-/color-convert)
4
5Color-convert is a color conversion library for JavaScript and node.
6It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
7
8```js
9var convert = require('color-convert');
10
11convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
12convert.keyword.rgb('blue'); // [0, 0, 255]
13
14var rgbChannels = convert.rgb.channels; // 3
15var cmykChannels = convert.cmyk.channels; // 4
16var ansiChannels = convert.ansi16.channels; // 1
17```
18
19# Install
20
21```console
22$ npm install color-convert
23```
24
25# API
26
27Simply get the property of the _from_ and _to_ conversion that you're looking for.
28
29All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function.
30
31All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
32
33```js
34var convert = require('color-convert');
35
36// Hex to LAB
37convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
38convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
39
40// RGB to CMYK
41convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
42convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
43```
44
45### Arrays
46All functions that accept multiple arguments also support passing an array.
47
48Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
49
50```js
51var convert = require('color-convert');
52
53convert.rgb.hex(123, 45, 67); // '7B2D43'
54convert.rgb.hex([123, 45, 67]); // '7B2D43'
55```
56
57## Routing
58
59Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex).
60
61Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js).
62
63# Contribute
64
65If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.
66
67# License
68Copyright &copy; 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).
Note: See TracBrowser for help on using the repository browser.