phi*_*hag 31
使用加密哈希并剪切您不需要的字节:
function getColor($num) {
$hash = md5('color' . $num); // modify 'color' to get a different palette
return array(
hexdec(substr($hash, 0, 2)), // r
hexdec(substr($hash, 2, 2)), // g
hexdec(substr($hash, 4, 2))); //b
}
Run Code Online (Sandbox Code Playgroud)
结果(生成它的代码)对于数字0-20看起来像这样:
