A discussion in chat revealed it would be probably better to generate a unique color from the account name and then mod it into one of N colors of a given, and later customizable, color palette.
The color selection should be if available account-based, and gracefully degrade to nickname-based in absence of an account.
Possible implementation:
(name: string, psize: number) => [...name].map(c => c.charCodeAt(0)).reduce((a, b) => a + b) % psize
Where name is account | nick, and psize is the palette size N of an array palette of RGB values whose indices go from 0 to N-1.
A discussion in chat revealed it would be probably better to generate a unique color from the account name and then mod it into one of N colors of a given, and later customizable, color palette.
The color selection should be if available account-based, and gracefully degrade to nickname-based in absence of an account.
Possible implementation:
Where
name
isaccount | nick
, andpsize
is the palette size N of an array palette of RGB values whose indices go from 0 to N-1.