README: add RGB color conversion example#2
Conversation
|
The |
|
Sorry, when copied I removed the line. I updated the PR. Also it turned out that this is not enough for the Here is a sample: HsluvColorConverter conv = new HsluvColorConverter();
conv.hsluv_s = 100;
conv.hsluv_l = 50;
conv.hsluv_h = 128; // 128...255
conv.hsluvToRgb();
System.out.println(conv.rgb_r); //=> -2.2506760344320753E-13This is a very small value but still it's negative. So in fact it needs for an additional rounding and most implementations do have it, e.g. Conversations: return Color.rgb(
(int) Math.round(converter.rgb_r * 255),
(int) Math.round(converter.rgb_g * 255),
(int) Math.round(converter.rgb_b * 255));Here it uses conversion to So could you add a check to avoid negative values? Or maybe there are also possible values bigger than upper range. This was a difficult to catch and understand for me because I never worked with colors and faced the exception in runtime after some testing. It might be a bug on production. |
|
Looks good, thanks! |
No description provided.