{"_id":"color-temperature","_rev":"6-48f8ab4e9db8e6e9eaec73ada84dbeb7","name":"color-temperature","description":"Kelvin color temperature to RGB convertor","dist-tags":{"latest":"0.2.7"},"versions":{"0.2.6":{"name":"color-temperature","version":"0.2.6","description":"Kelvin color temperature to RGB convertor","main":"index.js","private":false,"dependencies":{},"scripts":{"test":"\"echo \"Error: no test specified\" && exit 1\""},"repository":{"type":"git","url":"https://github.com/neilbartlett/color-temperature.git"},"keywords":["color","temperature","kelvin","colour","RGB","black body","spectrum"],"author":{"name":"Neil Bartlett","email":"neil.e.bartlett@gmail.com","url":"http://neilbartlett.com"},"license":"MIT","bugs":{"url":"https://github.com/neilbartlett/color-temperature/issues"},"homepage":"https://github.com/neilbartlett/color-temperature","gitHead":"b2fe1ade912e96857ba5a028ebd8de4909b9043a","_id":"color-temperature@0.2.6","_shasum":"caddbce60bfbecaf8314f72e1f55c57d9856817a","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"neilbartlett","email":"neil.e.bartlett@gmail.com"},"maintainers":[{"name":"neilbartlett","email":"neil.e.bartlett@gmail.com"}],"dist":{"shasum":"caddbce60bfbecaf8314f72e1f55c57d9856817a","tarball":"https://registry.npmjs.org/color-temperature/-/color-temperature-0.2.6.tgz","integrity":"sha512-QDPtXM4Yby5y2z3+nRwqFI30Q9TW0erOzSONmaOcjSVVDoPz/OnyVjfNAXcOh1vSGd4RzekDz5HAXWKJdir7iw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCKzjwPwWT0JWS8oqVCD9IovzB+e+qhns5/CxhisOaN4QIgWXnvPXBjPXHsatjNdcuS04qsoAeTuA7Ye1jasodW/Fs="}]}},"0.2.7":{"name":"color-temperature","version":"0.2.7","description":"Kelvin color temperature to RGB convertor","main":"index.js","private":false,"dependencies":{},"scripts":{"test":"\"echo \"Error: no test specified\" && exit 1\""},"repository":{"type":"git","url":"https://github.com/neilbartlett/color-temperature.git"},"keywords":["color","temperature","kelvin","colour","RGB","black body","spectrum"],"author":{"name":"Neil Bartlett","email":"neil.e.bartlett@gmail.com","url":"http://neilbartlett.com"},"license":"MIT","bugs":{"url":"https://github.com/neilbartlett/color-temperature/issues"},"homepage":"https://github.com/neilbartlett/color-temperature","gitHead":"513d2b48b789c47ab635a10b42daa28df1056da2","_id":"color-temperature@0.2.7","_shasum":"6c32ad9dd9c0fe07ccf2d8680734781712332b40","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"neilbartlett","email":"neil.e.bartlett@gmail.com"},"maintainers":[{"name":"neilbartlett","email":"neil.e.bartlett@gmail.com"}],"dist":{"shasum":"6c32ad9dd9c0fe07ccf2d8680734781712332b40","tarball":"https://registry.npmjs.org/color-temperature/-/color-temperature-0.2.7.tgz","integrity":"sha512-hFuGKuSBO4V2+AY4KAUvPr3fnNgfgSR1Kf3P1zp80t+zJF0Y37Z1VW2HZIPN90g29NkrlZK5ATIrDul7PCJYZA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEh12VXgkoUWwcSGmp0ItSvhN22YE/DUTiFt/5vnIGtYAiBWqwRXvcksZ4AZdQh3uOoU5zj+9BMkOntbxF9/pbLo/g=="}]}}},"readme":"color-temperature\n=================\n\n![Color Spectrum](http://neilbartlett.github.io/color-temperature/images/color-temperature-spectrum.png)\n\nConverts color temperature in Kelvin to a color in RGB color space -- and vice versa.\n\nThe conversion is designed to be fast and usable for image processing. More details on color temperature and the algorithm can be found [here](http://www.zombieprototypes.com/?p=210).\n\n## Installation\n\n`$ npm install --save color-temperture`\n\n## Usage\n\n```js\nvar ct = require('color-temperature');\n\n//convert kelvin to RGB\n// eg convert typical candlelight (1850K ) to RGB\nvar rgb = ct.colorTemperature2rgb(1850);\n\nvar red = rgb.red;\nvar green = rgb.green;\nvar blue = rgb.blue;\n```\n\nRGB color is represented in JSON format: An RGB of [0, 128, 255] would be represented as\n\n```js\n{\n  red : 0,\n  green : 128,\n  blue : 255\n}\n```\n## Examples\n\n\nOften, the convertor is deployed as part of an image processing loop. The following example uses streams to generate a PNG similar to that at the top of this README file.\n\n```js\nvar fs = require('fs');\nvar png_encoder = require('png-stream');\nvar ct = require('color-temperature');\nvar width = 500;\nvar height = 100;\nvar kelvinStart = 10;\nvar kelvinEnd = 40000;\n\nvar pixels = new Buffer(width * height * 3);\nfor (var w = 0; w < width; w += 1) {\n  for (var h = 0; h < height; h += 1) {\n      var i = ((h*width)+w)*3;\n\n      kelvin = ((kelvinEnd-kelvinStart)/width)* w + kelvinStart;\n      var rgb = ct.colorTemperature2rgb(kelvin);\n\n      pixels[i] = rgb.red;\n      pixels[i + 1] = rgb.green;\n      pixels[i + 2] = rgb.blue;\n  }\n}\n\nvar enc = new png_encoder.Encoder(width, height);\nenc.pipe(fs.createWriteStream('color-temperature-'+kelvinStart+'-'+kelvinEnd+'.png'));\nenc.end(pixels);\n```\nThere are examples in the examples directory.\n\n\n## API\n\n\nNOTE The conversions use approximations and are suitable for photo-mainpulation and other non-critical uses.\n\nAccuracy is best between 1000K and 40000K.\n\n\n```js\nrequire('color-temperature').colorTemperature2rgb(kelvin);\n```\nConvert a color temperature in Kelvin to RGB.\nThis method uses an approximation based on a curve fit of data from a sparse RGB to\nKelvin mapping.\n\n```js\nrequire('color-temperature').colorTemperature2rgbUsingTH(kelvin);\n```\nA JavaScript port of the original algorithm from Tanner Helland. This method\nis mainly here for comparison purposes. Generally, colorTemperature2rgb provides more\naccurate results.\n\n```js\nrequire('color-temperature').rgb2colorTemperature(rgb);\n```\n\nConvert a color in RGB format to a color temperature in Kelvin.\n\n\n## License\n\nThe code is released under an MIT license.\n\n## Release History\n\n* 0.1.0 Initial release\n\n[![NPM](https://nodei.co/npm/color-temperature.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/color-temperature/)\n","maintainers":[{"name":"neilbartlett","email":"neil.e.bartlett@gmail.com"}],"time":{"modified":"2022-06-13T06:31:36.343Z","created":"2015-03-19T19:31:42.562Z","0.2.6":"2015-03-19T19:31:42.562Z","0.2.7":"2015-03-21T04:40:57.959Z"},"homepage":"https://github.com/neilbartlett/color-temperature","keywords":["color","temperature","kelvin","colour","RGB","black body","spectrum"],"repository":{"type":"git","url":"https://github.com/neilbartlett/color-temperature.git"},"author":{"name":"Neil Bartlett","email":"neil.e.bartlett@gmail.com","url":"http://neilbartlett.com"},"bugs":{"url":"https://github.com/neilbartlett/color-temperature/issues"},"license":"MIT","readmeFilename":"README.md"}