mirror of
https://github.com/Dvorinka/SEEN.git
synced 2026-06-04 20:43:03 +00:00
16 lines
475 B
TypeScript
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'
|