davidmerfield/randomColor

What determins a luminosity of "Bright"

Xliff opened this issue · 3 comments

Xliff commented

@davidmerfield -- How are you defining "Bright" colors for RandomColor? I am attempting to write a numerical test for "bright" colors, and am wondering how it is defined in generation. From what I can see, it looks like the minumum saturation should be 55, however I can use this piece of code:

console.log(
  randomColor({
    seed: 2019021101,
    luminosity: 'bright',
    count: 5,
    format: 'hslArray'
  })
);

And the first color I get turns out to be [ 191, 53.43, 54.905 ], which has an S value lower than that. Can you please clarify?

Xliff commented

Just for shiz and grins, I took that sequence out until it looked stable. I generated 100,000 before the S min bottomed out at 37.93.

That seems to be a rather low S for "Bright" though.

That is curious, sounds like a bug. luminosity: 'bright' should always produce HSV colours with an S value greater than 55. Thank you for bringing this to my attention. Will investigate more deeply when I get a chance.

@davidmerfield I just checked the whole code and based on this statement “should always produce HSV colours with an S value greater than 55.”, the code works fine and actually there are no bugs in it. I checked “pickSaturation” function and it was perfectly fine (just a simple switch case to determine the range of saturation :) ) and to make sure, I checked the output. Then I checked “setFormat” function and its inputs (using ‘console.log(hsv);’) and again, everything worked round the clock and I concluded that hsv arguments are correct. I think @Xliff has misunderstood something or meant to use ‘hsvArray’ instead of ‘hslArray’ because saturation in hsl is calculated by a different formula. In short, if you want the ‘S’ value of hsl to be more than 55, you have to change the inputs or sMin, but if you want the ‘S’ value of hsv (or hsb) to be more than 55 (based on your last response), your code is perfectly fine :).