Qix- / color-convert

Plain color conversion functions in JavaScript
MIT License
746 stars 96 forks source link

hsl conversions are off #24

Closed kevinSuttle closed 8 years ago

kevinSuttle commented 8 years ago
var cc = require("color-convert")

var hslColors = ["250, 100%, 96%", "250,  98%, 86%", "250,  96%, 78%", 
"250,  12%, 46%", "30, 100%, 80%", "30, 72%, 62%", "30,  6%, 46%", "30, 72%, 62%", "250, 14%, 18%", "252, 14%, 28%", "30, 100%, 66%"];

for(var i=0; i < hslColors.length; i++){
  console.log(hslColors[i] +" in hex is " + cc.hsl2hex(hslColors[i]));
  console.log(hslColors[i] +" in ansi is " + cc.hsl2ansi(hslColors[i]));
  console.log(hslColors[i] +" in ansi16 is " + cc.hsl2ansi16(hslColors[i]));
}
250, 100%, 96% in hex is 000000
250, 100%, 96% in ansi is 16
250, 100%, 96% in ansi16 is 30
250,  98%, 86% in hex is 000000
250,  98%, 86% in ansi is 16
250,  98%, 86% in ansi16 is 30
250,  96%, 78% in hex is 000000
250,  96%, 78% in ansi is 16
250,  96%, 78% in ansi16 is 30
250,  12%, 46% in hex is 000000
250,  12%, 46% in ansi is 16
250,  12%, 46% in ansi16 is 30
30, 100%, 80% in hex is 000000
30, 100%, 80% in ansi is NaN
30, 100%, 80% in ansi16 is 30
30, 72%, 62% in hex is 000000
30, 72%, 62% in ansi is NaN
30, 72%, 62% in ansi16 is 30
30,  6%, 46% in hex is 000000
30,  6%, 46% in ansi is NaN
30,  6%, 46% in ansi16 is 30
30, 72%, 62% in hex is 000000
30, 72%, 62% in ansi is NaN
30, 72%, 62% in ansi16 is 30
250, 14%, 18% in hex is 000000
250, 14%, 18% in ansi is 16
250, 14%, 18% in ansi16 is 30
252, 14%, 28% in hex is 050505
252, 14%, 28% in ansi is 16
252, 14%, 28% in ansi16 is 30
30, 100%, 66% in hex is 000000
30, 100%, 66% in ansi is NaN
30, 100%, 66% in ansi16 is 30
Qix- commented 8 years ago

Hi! Don't use string values.

var cc = require("color-convert")

var hslColors = [
  [250, 100, 96],
  [250,  98, 86],
  [250,  96, 78],
  [250,  12, 46],
  [30,  100, 80],
  [30,   72, 62],
  [30,    6, 46],
  [30,   72, 62],
  [250,  14, 18],
  [252,  14, 28],
  [30,  100, 66]
];

for(var i=0; i < hslColors.length; i++){
  console.log(hslColors[i] +" in hex is " + cc.hsl2hex(hslColors[i]));
  console.log(hslColors[i] +" in ansi is " + cc.hsl2ansi(hslColors[i]));
  console.log(hslColors[i] +" in ansi16 is " + cc.hsl2ansi16(hslColors[i]));
}
kevinSuttle commented 8 years ago

Ah, ok.

Qix- commented 8 years ago

:dancer: Might be looking for color-string.

kevinSuttle commented 8 years ago

Thanks.