1036 | 1036 | // First create the color in RGB then HSL, clamp the lightness so it's not too dark to read, and then convert back to RGB to display. |
1037 | 1037 | // The reason for this roundabout method is this algorithm can generate values from 0 to 255 for RGB but only 0 to 100 for HSL; this gives |
1038 | 1038 | // us much more variety if we generate in RGB. Unfortunately, enforcing that RGB values are a certain lightness is very difficult, so |
1039 | 1039 | // we convert to HSL to do the computation. Since our GUI code only displays RGB colors, we have to convert back. |
1040 | 1040 | var [h, s, l] = rgbToHsl(hash >> 24 & 0xFF, hash >> 16 & 0xFF, hash >> 8 & 0xFF); |