【发布时间】:2017-05-06 15:46:23
【问题描述】:
我正在使用以下函数来生成柔和的颜色。但有时它会产生深色调(如#B69C97)。如何确保只生成浅色阴影?
function get_color($name) {
$hash = md5($name);
$color1 = hexdec(substr($hash, 8, 2));
$color2 = hexdec(substr($hash, 4, 2));
$color3 = hexdec(substr($hash, 0, 2));
if($color1 < 128) $color1 += 128;
if($color2 < 128) $color2 += 128;
if($color3 < 128) $color3 += 128;
return "#" . dechex($color1) . dechex($color2) . dechex($color3);
}
【问题讨论】:
-
你试过我的答案了吗?有帮助吗?