Php convert string to hex color
I agree with sje397 above that completely random colours could end up looking nasty. Rather than make a long list of nice-looking colours, I would suggest choosing a constant saturation+luminescence value, and varying the hue based on the content. To get an RGB colour from an HSL colour, you may use something similar to what's described in http://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB . Here's an example (try it in http://codepad.viper-7.com something that works, such as https://codepad.remoteinterview.io/ZXBMZWYJFO): Generate a unique color based on text input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|