算法:从字符串创建颜色

MOn*_*DaR 8 algorithm colors

我想从给定的字符串创建一种颜色.字符串不必与任何形式的结果颜色相关,但相同的字符串应始终产生相同的颜色.

这个问题不受特定编程语言的约束,因此"颜色"应该采用与RGB无关的语言格式.

如果算法在宽色谱中创建颜色而不仅仅是灰色,那将是很好的.

完全是这样的(C++):

#include <string>

int getRedFromString( std::string givenString )
{ /*Your code here...*/ }

int getGreenFromString( std::string givenString )
{ /*Your code here...*/ }

int getBlueFromString( std::string givenString )
{ /*Your code here...*/ }

int main()
{
    std::string colorString = "FooBar";
    int R = getRedFromString  ( colorString );
    int G = getGreenFromString( colorString );
    int B = getBlueFromString ( colorString );
}
Run Code Online (Sandbox Code Playgroud)

SLa*_*aks 10

获取字符串的哈希值,然后使用哈希值的前三个字节作为红色,蓝色和绿色值.