Qix-/color-convert

Convertation is differrent #101

mcfly10 posted onGitHub

Hi,

I getting different values converting from RGB to HSL and then back

var convert = require('color-convert');

console.log("A38E8E", " => ", convert.hex.hsl("A38E8E")); // Result A38E8E
console.log([0, 10, 60], " => ", convert.hsl.hex(0, 10, 60)); // Result A38F8F. Expected A38E8E

Converting A38E8E I get [0, 10, 60] Converting [0, 10, 60] I get A38F8F. Not A38E8E!


https://github.com/Qix-/color-convert#api

Please read about rounding. Use .raw() if you need to preserve accuracy. Also, keep in mind hex will always truncate, which means you're losing data. Conversion between HSL and RGB is not perfect.

> console.log(convert.hsl.hex(convert.hex.hsl('A38E8E')))
A38F8F

> console.log(convert.hsl.hex(convert.hex.hsl.raw('A38E8E')))
A38E8E
posted by Qix- over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests