Closed Haraldson closed 7 years ago
I'm not the project owner or anything, but it wouldn't be hard to write this with some modulo operations. Something like:
function userColor(userId) {
return chroma.hsl(userId % 360, 30 + (userId % 71), 40 + (userId % 56)).css();
}
This should generate a color with hue 0–359, saturation 30–100, lightness 40–95.
I wouldn't hold my breath for this to be added to chroma.js.
My user IDs are email addresses in this scenario. I’m not claiming there are no ways to achieve what I want in multiple steps, just proposing an idea that would make generating deterministic (I learned a new word, yay!) colors easier. :)
Funny you just opened this - I came here for the same thing!
I want a deterministic way of generating random colors - but within a chroma.js range. I was using a different implementation - it'd be great if Chroma.js could provide this functionality!
there are only so many colors humans can differentiate, so this is not a trivial task, and there is probably no color-only solution for more than ~10 users. I would probably just use something like chroma.brewer.Set3
and then overlay the color with a random symbol. I really like the color+animal combination google is using for docs.
I’m looking for a simple way of associating random colors to users to make them easily recognizable in a collaborative environment. I wanted to use Chroma for this, as there are neat methods to ensure that colors look nice – at least that they’re within a given luminance range for instance.
My idea is to use a user’s ID as a unique value to pass into the random function to ensure that the returned color will always be the same for the same user, but this is not currently supported.
Is this an idea that would fit into your project and that you would consider implementing at one point?