Qix-/color-convert

Failure to convert RGB to HSL and back #85

marnec posted onGitHub

input:

console.log(r, g, b);
console.log(convert.rgb.hsl(...convert.hsl.rgb(r,g,b)))

output:

0 51 255
[180, -51, 255]

Because you're passing RGB values to hsl.rgb() which means convert hsl to rgb - the functions are structured so that require('color-convert').from_model.to_model(...).

You need to invert the function calls:

console.log(convert.hsl.rgb(...convert.rgb.hsl(r,g,b)))
posted by Qix- over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests