I managed to generate a random hex color from a string :
function StringToColorFilter() {
var hashString = function (chaine) {
var hash = 0, i, chr, len;
if (chaine.length == 0)
return hash;
for (i = 0, len = chaine.length; i < len; i++) {
chr = chaine.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
return function (chaine) {
return "#" + ("FFFFFF" + Math.abs(hashString(chaine) % 16777216).toString(16)).substr(-6);
};
}
Example : StringToColorFilter()("MyString")
=> #393303
(no luck this color suxx)
So now :
- I want to avoid white, bland, graying or pale colors
- I want to generate only intense/strong/colorful colors
I first tried to remove one component (red, green, or blue) or two, but that removes too many possibilities and i can still have ugly colors.
Then i tried to remove extremum (F/E and 0/1) values. But i can still have grey.
Some algorithm ideas ?