var name refine

This commit is contained in:
shinemoon 2023-11-17 21:27:15 +08:00
parent 42baabc0e1
commit 877e56d81c

View file

@ -31,10 +31,10 @@ const stringToColour = (str) => {
str.split('').forEach(char => { str.split('').forEach(char => {
hash = char.charCodeAt(0) + ((hash << 5) - hash) hash = char.charCodeAt(0) + ((hash << 5) - hash)
}) })
let colour = '#' let color = '#';
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
const value = (hash >> (i * 8)) & 0xff const value = (hash >> (i * 8)) & 0xff
colour += value.toString(16).padStart(2, '0') color += value.toString(16).padStart(2, '0')
} }
return colour return color;
}; };