kelvin-to-rgb

approximate an RGB color from a Kelvin temperature

Usage no npm install needed!

<script type="module">
  import kelvinToRgb from 'https://cdn.skypack.dev/kelvin-to-rgb';
</script>

README

kelvin-to-rgb

stable

demo

(demo) - (source)

Approximate an [r, g, b] color from a Kelvin temperature between 1,500 and 40,000.

Details and original implementation by Tanner Helland, see here.

Example

var kelvinToRgb = require('kelvin-to-rgb')
var K = 1600

// get [ r, g, b ] color
var rgb = kelvinToRgb(K)

Install

npm install kelvin-to-rgb --save

Usage

NPM

rgb = kelvinToRGB(kelvin, [out])

Approximates the color temperature for the given kelvin value (should be between 1500 - 40000). Returns a new array, [r, g, b] with bytes in 0 - 255 range.

If out is specified and it is an array, it will be used instead of creating a new array (this is useful to avoid GC thrashing).

License

MIT, see LICENSE.md for details.