Fix string to hex conversion
This commit is contained in:
parent
dd195c7b04
commit
d883cf7940
1 changed files with 2 additions and 2 deletions
|
@ -12,10 +12,10 @@ export default function string2hex(str: string): string {
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
// Ensuring minimum brightness for each component to make text stand out
|
// Ensuring minimum brightness for each component to make text stand out
|
||||||
// Adjust the minimum brightness as needed (e.g., 0x80 for brighter colors)
|
// Adjust the minimum brightness as needed (e.g., 0x80 for brighter colors)
|
||||||
const minBrightness = 0x80
|
const minBrightness = 0xa0 // Increased min brightness
|
||||||
const value =
|
const value =
|
||||||
(((hash >> (i * 8)) & 0xff) % (0xff - minBrightness)) + minBrightness
|
(((hash >> (i * 8)) & 0xff) % (0xff - minBrightness)) + minBrightness
|
||||||
color += ('00' + value.toString(16)).substr(-2)
|
color += ('00' + value.toString(16)).slice(-2)
|
||||||
}
|
}
|
||||||
|
|
||||||
return color
|
return color
|
||||||
|
|
Loading…
Reference in a new issue