Skip to content
Permalink
Browse files

Add GET request 'HSL'

  • Loading branch information...
peter-stuhlmann committed Jul 18, 2019
1 parent 1759422 commit 11873318adb20b422eca4411a89bb7d2c438555a
Showing with 28 additions and 0 deletions.
  1. +28 −0 v1/converter/converter.js
@@ -89,6 +89,34 @@ router.get('/hex', (req, res) => {
);
});

router.get('/hsl', (req, res) => {

// HSL
const hslColor = req.query.color.split(',').map(colorValue => parseInt(colorValue));
const [hue, saturation, luminance] = hslColor;

// HEX
const hexOutput = convert.hsl.hex(hslColor);
const hex = hexOutput;

// COLOR NAME
const colorname = convert.hex.keyword(hex);

// RGB
const rgbColor = convert.hsl.rgb(hslColor);
const [red, green, blue] = rgbColor;

// Response
return res.json(
{
colorname,
hex,
hsl: { hue, saturation, luminance },
rgb: { red, green, blue }
}
);
});


// Each of the following requests returns only one value:

0 comments on commit 1187331

Please sign in to comment.
You can’t perform that action at this time.