in lib/@uncharted/cards/src/util/images.js [13:38]
export function grayShadeFromString(str, min, max) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
const color32bit = (hash & 0xFFFFFF);
let r = (color32bit >> 16) & 255;
let g = (color32bit >> 8) & 255;
let b = color32bit & 255;
/* clamp the colors */
if (min !== undefined) {
r = Math.max(r, min);
g = Math.max(g, min);
b = Math.max(b, min);
}
if (max !== undefined) {
r = Math.min(r, max);
g = Math.min(g, max);
b = Math.min(b, max);
}
return Math.floor((r + g + b) / 3);
}