Files
SEEN/frontend/src/utils/artwork.ts
T
2026-04-10 12:06:24 +02:00

16 lines
475 B
TypeScript

export type ArtworkTone = 'neutral' | 'accent' | 'secondary'
const hashSeed = (seed: string): number => {
let hash = 0
for (let index = 0; index < seed.length; index += 1) {
hash = (hash << 5) - hash + seed.charCodeAt(index)
hash |= 0
}
return Math.abs(hash)
}
const artworkTones: ArtworkTone[] = ['neutral', 'accent', 'secondary']
export const artworkTone = (seed: string): ArtworkTone =>
artworkTones[hashSeed(seed) % artworkTones.length] ?? 'neutral'