@charlesstover/hsl2rgb

Convert HSL to RGB.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
15Aug 3, 2021Jul 13, 2018Minified + gzip package size for @charlesstover/hsl2rgb in KB

Readme

hsl2rgb

Convert HSL to RGB.

package build downloads minified size minzipped size

Install

  • npm install @charlesstover/hsl2rgb --save or
  • yarn add @charlesstover/hsl2rgb

Test

npm test

Use

import hsl2rgb from '@charlesstover/hsl2rgb';

const [ r, g, b ] = hsl2rgb(0, 1, 0.5);
console.log(r); // 1
console.log(g); // 0
console.log(b); // 0

const css = (h, s, l) => 'rgb(' + hsl2rgb(h, s, l).map((x) => x * 255).join(', ') + ')';

console.log(css(0.5, 1, 0.5)); // rgb(0, 255, 0)

Parameters

  • hue: number The hue, from 0 to 1.

  • saturation: number The saturation, from 0 to 1. Zero is black and white; one is full color.

  • lightness: number The lightness, from 0 to 1. Zero is black. One half is full color. One is white.

Return Value

This function returns an array of three numbers: red, green, and blue. Each is a decimal value from 0 to 1.

See also

For example colors and their HSL and RGB equivalents, check out the X11 color name chart.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.