\href{https://travis-ci.org/Qix-/color-convert}{\texttt{ }}

Color-\/convert is a color conversion library for Java\+Script and node. It converts all ways between {\ttfamily rgb}, {\ttfamily hsl}, {\ttfamily hsv}, {\ttfamily hwb}, {\ttfamily cmyk}, {\ttfamily ansi}, {\ttfamily ansi16}, {\ttfamily hex} strings, and CSS {\ttfamily keyword}s (will round to closest)\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var convert = require('color-\/convert');}
\DoxyCodeLine{}
\DoxyCodeLine{convert.rgb.hsl(140, 200, 100);             // [96, 48, 59]}
\DoxyCodeLine{convert.keyword.rgb('blue');                // [0, 0, 255]}
\DoxyCodeLine{}
\DoxyCodeLine{var rgbChannels = convert.rgb.channels;     // 3}
\DoxyCodeLine{var cmykChannels = convert.cmyk.channels;   // 4}
\DoxyCodeLine{var ansiChannels = convert.ansi16.channels; // 1 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16203}{}\doxysection{Install}\label{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16203}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install color-\/convert }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16204}{}\doxysection{API}\label{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16204}
Simply get the property of the {\itshape from} and {\itshape to} conversion that you\textquotesingle{}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 {\ttfamily .raw} to the function.

All \textquotesingle{}from\textquotesingle{} functions have a hidden property called {\ttfamily .channels} that indicates the number of channels the function expects (not including alpha).


\begin{DoxyCode}{0}
\DoxyCodeLine{var convert = require('color-\/convert');}
\DoxyCodeLine{}
\DoxyCodeLine{// Hex to LAB}
\DoxyCodeLine{convert.hex.lab('DEADBF');         // [ 76, 21, -\/2 ]}
\DoxyCodeLine{convert.hex.lab.raw('DEADBF');     // [ 75.56213190997677, 20.653827952644754, -\/2.290532499330533 ]}
\DoxyCodeLine{}
\DoxyCodeLine{// RGB to CMYK}
\DoxyCodeLine{convert.rgb.cmyk(167, 255, 4);     // [ 35, 0, 98, 0 ]}
\DoxyCodeLine{convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16205}{}\doxysubsubsection{Arrays}\label{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16205}
All functions that accept multiple arguments also support passing an array.

Note that this does {\bfseries{not}} apply to functions that convert from a color that only requires one value (e.\+g. {\ttfamily keyword}, {\ttfamily ansi256}, {\ttfamily hex}, etc.)


\begin{DoxyCode}{0}
\DoxyCodeLine{var convert = require('color-\/convert');}
\DoxyCodeLine{}
\DoxyCodeLine{convert.rgb.hex(123, 45, 67);      // '7B2D43'}
\DoxyCodeLine{convert.rgb.hex([123, 45, 67]);    // '7B2D43' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16206}{}\doxysubsection{Routing}\label{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16206}
Conversions that don\textquotesingle{}t have an {\itshape explicitly} defined conversion (in \href{conversions.js}{\texttt{ conversions.\+js}}), but can be converted by means of sub-\/conversions (e.\+g. XYZ -\/$>$ {\bfseries{RGB}} -\/$>$ CMYK), are automatically routed together. This allows just about any color model supported by {\ttfamily 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 -\/$>$ {\bfseries{LAB}} -\/$>$ {\bfseries{XYZ}} -\/$>$ {\bfseries{RGB}} -\/$>$ Hex).

Keep in mind that extensive conversions {\itshape may} result in a loss of precision, and exist only to be complete. For a list of \char`\"{}direct\char`\"{} (single-\/step) conversions, see \href{conversions.js}{\texttt{ conversions.\+js}}.\hypertarget{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16207}{}\doxysection{Contribute}\label{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16207}
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.\hypertarget{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16208}{}\doxysection{License}\label{md_sfcode_node_modules_log_symbols_node_modules_color_convert_README_autotoc_md16208}
Copyright \copyright{} 2011-\/2016, Heather Arthur and Josh Junon. Licensed under the \mbox{[}MIT License\mbox{]}(LICENSE). 