color-convert / 1.3.1 last updated 4 months ago created on Jun 10th 2011
Install
npm install --save color-convert
Clone
git clone git@github.com:qix-/color-convert.git
dependencies
No dependencies listed.
maintainers
versions
19 total
| 1.3.1 | 4 months ago | qix |
| 1.3.0 | 4 months ago | qix |
| 1.2.2 | 4 months ago | qix |
| 1.2.1 | 4 months ago | qix |
| 1.2.0 | 4 months ago | qix |
| 1.1.2 | 4 months ago | qix |
| 1.1.1 | 4 months ago | qix |
| 1.1.0 | 4 months ago | qix |
| 1.0.0 | 7 months ago | qix |
| 0.7.0 | 8 months ago | qix |
| 0.6.0 | a year ago | moox |
| 0.5.3 | a year ago | moox |
| 0.5.2 | 2 years ago | harth |
| 0.5.1 | 2 years ago | harth |
| 0.5.0 | 2 years ago | harth |
| 0.4.0 | 2 years ago | harth |
| 0.3.4 | 2 years ago | harth |
| 0.3.1 | 5 years ago | harth |
| 0.3.0 | 5 years ago | harth |
readme
color-convert
Color-convert is a color conversion library for JavaScript and node.
It converts all ways between rgb, hsl, hsv, hwb, cmyk, ansi, ansi16, hex strings, and CSS keywords:
Install
API
Simply get the property of the from and to conversion that you're looking for.
All 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.
All 'from' functions have a hidden property called .channels that indicates the number of channels the function expects (not including alpha).
Arrays
All functions that accept multiple arguments also support passing an array.
Note that this does not apply to functions that convert from a color that only requires one value (e.g. keyword, ansi256, hex, etc.)
Routing
Conversions that don't have an explicitly defined conversion (in 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).
Keep 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.
Contribute
If 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.
License
Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under the MIT License.