Fix string to hex conversion

This commit is contained in:
Ananth Venkatesh 2024-02-15 21:17:36 +00:00
parent dd195c7b04
commit d883cf7940

View file

@ -12,10 +12,10 @@ export default function string2hex(str: string): string {
for (let i = 0; i < 3; i++) {
// Ensuring minimum brightness for each component to make text stand out
// Adjust the minimum brightness as needed (e.g., 0x80 for brighter colors)
const minBrightness = 0x80
const minBrightness = 0xa0 // Increased min brightness
const value =
(((hash >> (i * 8)) & 0xff) % (0xff - minBrightness)) + minBrightness
color += ('00' + value.toString(16)).substr(-2)
color += ('00' + value.toString(16)).slice(-2)
}
return color