{"name":"color","version":"5.0.0","description":"Color conversion and manipulation with CSS string support","type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"keywords":["color","colour","css"],"authors":["Josh Junon <josh@junon.me>","Heather Arthur <fayearthur@gmail.com>","Maxime Thirouin"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Qix-/color.git"},"xo":{"rules":{"no-bitwise":0,"no-cond-assign":0,"new-cap":0,"unicorn/prefer-module":0,"no-mixed-operators":0,"complexity":0,"unicorn/numeric-separators-style":0}},"scripts":{"test":"xo && tsd && mocha"},"engines":{"node":">=18"},"dependencies":{"color-convert":"^3.0.1","color-string":"^2.0.0"},"devDependencies":{"mocha":"11.1.0","tsd":"0.31.2","xo":"0.60.0"},"_id":"color@5.0.0","gitHead":"fef7b619edd678455595b9b6a10780f13b58d285","bugs":{"url":"https://github.com/Qix-/color/issues"},"homepage":"https://github.com/Qix-/color#readme","_nodeVersion":"20.5.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-16BlyiuyLq3MLxpRWyOTiWsO3ii/eLQLJUQXBSNcxMBBSnyt1ee9YUdaozQp03ifwm5woztEZGDbk9RGVuCsdw==","shasum":"3583bf8f6a77cec41b329ea228dd05d2f5270218","tarball":"http://registry-npm.ywwl.com/color/download/color-5.0.0.tgz","fileCount":5,"unpackedSize":26347,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBSV2VCg9wiIOZ8e2dKLGy1/L39XVZMY+ynUSx/HbOm0AiEAkWLt1CFGKp1HKhO6D9bbpVAz4lo5rm9X6rPP0GjT2Oc="}],"size":7239,"noattachment":false,"key":"/color/-/color-5.0.0.tgz"},"_npmUser":{"name":"qix","email":"npm@josh.junon.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/color_5.0.0_1739359050803_0.5074974065624405"},"_hasShrinkwrap":false,"readme":"# color\n\n> JavaScript library for immutable color conversion and manipulation with support for CSS color strings.\n\n```js\nconst color = Color('#7743CE').alpha(0.5).lighten(0.5);\nconsole.log(color.hsl().string());  // 'hsla(262, 59%, 81%, 0.5)'\n\nconsole.log(color.cmyk().round().array());  // [ 16, 25, 0, 8, 0.5 ]\n\nconsole.log(color.ansi256().object());  // { ansi256: 183, alpha: 0.5 }\n```\n\n## Install\n```shell\nnpm install color\n```\n\n## Usage\n```js\nimport Color from 'color';\n```\n\n### Constructors\n```js\n// string constructor\nconst color = Color('rgb(255, 255, 255)')                       // { model: 'rgb', color: [ 255, 255, 255 ], valpha: 1 }\nconst color = Color('hsl(194, 53%, 79%)')                       // { model: 'hsl', color: [ 195, 53, 79 ], valpha: 1 }\nconst color = Color('hsl(194, 53%, 79%, 0.5)')                  // { model: 'hsl', color: [ 195, 53, 79 ], valpha: 0.5 }\nconst color = Color('#FF0000')                                  // { model: 'rgb', color: [ 255, 0, 0 ], valpha: 1 }\nconst color = Color('#FF000033')                                // { model: 'rgb', color: [ 255, 0, 0 ], valpha: 0.2 }\nconst color = Color('lightblue')                                // { model: 'rgb', color: [ 173, 216, 230 ], valpha: 1 }\nconst color = Color('purple')                                   // { model: 'rgb', color: [ 128, 0, 128 ], valpha: 1 }\n\n// rgb\nconst color = Color({r: 255, g: 255, b: 255})                   // { model: 'rgb', color: [ 255, 255, 255 ], valpha: 1 }\nconst color = Color({r: 255, g: 255, b: 255, alpha: 0.5})       // { model: 'rgb', color: [ 255, 255, 255 ], valpha: 0.5 }\nconst color = Color.rgb(255, 255, 255)                          // { model: 'rgb', color: [ 255, 255, 255 ], valpha: 1 }\nconst color = Color.rgb(255, 255, 255, 0.5)                     // { model: 'rgb', color: [ 255, 255, 255 ], valpha: 0.5 }\nconst color = Color.rgb(0xFF, 0x00, 0x00, 0.5)                  // { model: 'rgb', color: [ 255, 0, 0 ], valpha: 0.5 }\nconst color = Color.rgb([255, 255, 255])                        // { model: 'rgb', color: [ 255, 255, 255 ], valpha: 1 }\nconst color = Color.rgb([0xFF, 0x00, 0x00, 0.5])                // { model: 'rgb', color: [ 255, 0, 0 ], valpha: 0.5 }\n\n// hsl\nconst color = Color({h: 194, s: 53, l: 79})                     // { model: 'hsl', color: [ 195, 53, 79 ], valpha: 1 }\nconst color = Color({h: 194, s: 53, l: 79, alpha: 0.5})         // { model: 'hsl', color: [ 195, 53, 79 ], valpha: 0.5 }\nconst color = Color.hsl(194, 53, 79)                            // { model: 'hsl', color: [ 195, 53, 79 ], valpha: 1 }\n\n// hsv\nconst color = Color({h: 195, s: 25, v: 99})                     // { model: 'hsv', color: [ 195, 25, 99 ], valpha: 1 }\nconst color = Color({h: 195, s: 25, v: 99, alpha: 0.5})         // { model: 'hsv', color: [ 195, 25, 99 ], valpha: 0.5 }\nconst color = Color.hsv(195, 25, 99)                            // { model: 'hsv', color: [ 195, 25, 99 ], valpha: 1 }\nconst color = Color.hsv([195, 25, 99])                          // { model: 'hsv', color: [ 195, 25, 99 ], valpha: 1 }\n\n// cmyk\nconst color = Color({c: 0, m: 100, y: 100, k: 0})               // { model: 'cmyk', color: [ 0, 100, 100, 0 ], valpha: 1 }\nconst color = Color({c: 0, m: 100, y: 100, k: 0, alpha: 0.5})   // { model: 'cmyk', color: [ 0, 100, 100, 0 ], valpha: 0.5 }\nconst color = Color.cmyk(0, 100, 100, 0)                        // { model: 'cmyk', color: [ 0, 100, 100, 0 ], valpha: 1 }\nconst color = Color.cmyk(0, 100, 100, 0, 0.5)                   // { model: 'cmyk', color: [ 0, 100, 100, 0 ], valpha: 0.5 }\n\n// hwb\nconst color = Color({h: 180, w: 0, b: 0})                       // { model: 'hwb', color: [ 180, 0, 0 ], valpha: 1 }\nconst color = Color.hwb(180, 0, 0)                              // { model: 'hwb', color: [ 180, 0, 0 ], valpha: 1 }\n\n// lch\nconst color = Color({l: 53, c: 105, h: 40})                     // { model: 'lch', color: [ 53, 105, 40 ], valpha: 1 }\nconst color = Color.lch(53, 105, 40)                            // { model: 'lch', color: [ 53, 105, 40 ], valpha: 1 }\n\n// lab\nconst color = Color({l: 53, a: 80, b: 67})                      // { model: 'lab', color: [ 53, 80, 67 ], valpha: 1 }\nconst color = Color.lab(53, 80, 67)                             // { model: 'lab', color: [ 53, 80, 67 ], valpha: 1 }\n\n// hcg\nconst color = Color({h: 0, c: 100, g: 0})                       // { model: 'hcg', color: [ 0, 100, 0 ], valpha: 1 }\nconst color = Color.hcg(0, 100, 0)                              // { model: 'hcg', color: [ 0, 100, 0 ], valpha: 1 }\n\n// ansi16\nconst color = Color.ansi16(91)                                  // { model: 'ansi16', color: [ 91 ], valpha: 1 }\nconst color = Color.ansi16(91, 0.5)                             // { model: 'ansi16', color: [ 91 ], valpha: 0.5 }\n\n// ansi256\nconst color = Color.ansi256(196)                                // { model: 'ansi256', color: [ 196 ], valpha: 1 }\nconst color = Color.ansi256(196, 0.5)                           // { model: 'ansi256', color: [ 196 ], valpha: 0.5 }\n\n// apple\nconst color = Color.apple(65535, 65535, 65535)                  // { model: 'apple', color: [ 65535, 65535, 65535 ], valpha: 1 }\nconst color = Color.apple([65535, 65535, 65535])                // { model: 'apple', color: [ 65535, 65535, 65535 ], valpha: 1 }\n\n\n```\n\nSet the values for individual channels with `alpha`, `red`, `green`, `blue`, `hue`, `saturationl` (hsl), `saturationv` (hsv), `lightness`, `whiteness`, `blackness`, `cyan`, `magenta`, `yellow`, `black`\n\nString constructors are handled by [color-string](https://www.npmjs.com/package/color-string)\n\n### Getters\n```js\ncolor.hsl()\n```\nConvert a color to a different space (`hsl()`, `cmyk()`, etc.).\n\n```js\ncolor.object() // {r: 255, g: 255, b: 255}\n```\nGet a hash of the color value. Reflects the color's current model (see above).\n\n```js\ncolor.rgb().array() // [255, 255, 255]\n```\nGet an array of the values with `array()`. Reflects the color's current model (see above).\n\n```js\ncolor.rgbNumber() // 16777215 (0xffffff)\n```\nGet the rgb number value.\n\n```js\ncolor.hex() // #ffffff\n```\nGet the hex value. (**NOTE:** `.hex()` does not return alpha values; use `.hexa()` for an RGBA representation)\n\n```js\ncolor.red() // 255\n```\nGet the value for an individual channel.\n\n### CSS Strings\n```js\ncolor.hsl().string() // 'hsl(320, 50%, 100%)'\n```\n\nCalling `.string()` with a number rounds the numbers to that decimal place. It defaults to 1.\n\n### Luminosity\n```js\ncolor.luminosity(); // 0.412\n```\nThe [WCAG luminosity](http://www.w3.org/TR/WCAG20/#relativeluminancedef) of the color. 0 is black, 1 is white.\n\n```js\ncolor.contrast(Color(\"blue\")) // 12\n```\nThe [WCAG contrast ratio](http://www.w3.org/TR/WCAG20/#contrast-ratiodef) to another color, from 1 (same color) to 21 (contrast b/w white and black).\n\n```js\ncolor.isLight()  // true\ncolor.isDark()   // false\n```\nGet whether the color is \"light\" or \"dark\", useful for deciding text color.\n\n### Manipulation\n```js\ncolor.negate()         // rgb(0, 100, 255) -> rgb(255, 155, 0)\n\ncolor.lighten(0.5)     // hsl(100, 50%, 50%) -> hsl(100, 50%, 75%)\ncolor.lighten(0.5)     // hsl(100, 50%, 0)   -> hsl(100, 50%, 0)\ncolor.darken(0.5)      // hsl(100, 50%, 50%) -> hsl(100, 50%, 25%)\ncolor.darken(0.5)      // hsl(100, 50%, 0)   -> hsl(100, 50%, 0)\n\ncolor.lightness(50)    // hsl(100, 50%, 10%) -> hsl(100, 50%, 50%)\n\ncolor.saturate(0.5)    // hsl(100, 50%, 50%) -> hsl(100, 75%, 50%)\ncolor.desaturate(0.5)  // hsl(100, 50%, 50%) -> hsl(100, 25%, 50%)\ncolor.grayscale()      // #5CBF54 -> #969696\n\ncolor.whiten(0.5)      // hwb(100, 50%, 50%) -> hwb(100, 75%, 50%)\ncolor.blacken(0.5)     // hwb(100, 50%, 50%) -> hwb(100, 50%, 75%)\n\ncolor.fade(0.5)        // rgba(10, 10, 10, 0.8) -> rgba(10, 10, 10, 0.4)\ncolor.opaquer(0.5)     // rgba(10, 10, 10, 0.8) -> rgba(10, 10, 10, 1.0)\n\ncolor.rotate(180)      // hsl(60, 20%, 20%) -> hsl(240, 20%, 20%)\ncolor.rotate(-90)      // hsl(60, 20%, 20%) -> hsl(330, 20%, 20%)\n\ncolor.mix(Color(\"yellow\"))        // cyan -> rgb(128, 255, 128)\ncolor.mix(Color(\"yellow\"), 0.3)   // cyan -> rgb(77, 255, 179)\n\n// chaining\ncolor.green(100).grayscale().lighten(0.6)\n```\n\n## Propers\nThe API was inspired by [color-js](https://github.com/brehaut/color-js). Manipulation functions by CSS tools like Sass, LESS, and Stylus.\n","publish_time":1739359050996,"maintainers":[{"name":"qix","email":"npm@josh.junon.me"}],"_cnpm_publish_time":1739359050996,"dist-tags":{"latest":"5.0.3"}}