nhexirc / nhex

A next-generation IRC client inspired by HexChat
https://nhexirc.com
19 stars 0 forks source link

Revisit nickname coloring using a palette #41

Closed terrablue closed 8 months ago

terrablue commented 8 months ago

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.