Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # color-convert
  2. [![Build Status](https://travis-ci.org/Qix-/color-convert.svg?branch=master)](https://travis-ci.org/Qix-/color-convert)
  3. Color-convert is a color conversion library for JavaScript and node.
  4. It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
  5. ```js
  6. var convert = require('color-convert');
  7. convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
  8. convert.keyword.rgb('blue'); // [0, 0, 255]
  9. var rgbChannels = convert.rgb.channels; // 3
  10. var cmykChannels = convert.cmyk.channels; // 4
  11. var ansiChannels = convert.ansi16.channels; // 1
  12. ```
  13. # Install
  14. ```console
  15. $ npm install color-convert
  16. ```
  17. # API
  18. Simply get the property of the _from_ and _to_ conversion that you're looking for.
  19. 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.
  20. All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
  21. ```js
  22. var convert = require('color-convert');
  23. // Hex to LAB
  24. convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
  25. convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
  26. // RGB to CMYK
  27. convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
  28. convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
  29. ```
  30. ### Arrays
  31. All functions that accept multiple arguments also support passing an array.
  32. Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
  33. ```js
  34. var convert = require('color-convert');
  35. convert.rgb.hex(123, 45, 67); // '7B2D43'
  36. convert.rgb.hex([123, 45, 67]); // '7B2D43'
  37. ```
  38. ## Routing
  39. Conversions 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).
  40. 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](conversions.js).
  41. # Contribute
  42. 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.
  43. # License
  44. Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).