<?php
function usercolor( $username ) {
$range = 192 - 64;
$factor = $range / 256;
$offset = 64;
$base_hash = substr(md5($username), 0, 6);
$b_R = hexdec(substr($base_hash,0,2));
$b_G = hexdec(substr($base_hash,2,2));
$b_B = hexdec(substr($base_hash,4,2));
$f_R = floor((floor($b_R * $factor) + $offset) / 16) * COL_STEP;
$f_G = floor((floor($b_G * $factor) + $offset) / 16) * COL_STEP;
$f_B = floor((floor($b_B * $factor) + $offset) / 16) * COL_STEP;
return printf('#%02x%02x%02x', $f_R, $f_G, $f_B);
}
for( $i=0; $i<30; $i++ ) {
printf('<div style="height: 100px; width: 100px; background-color: %s"> </div>'."\n", usercolor(rand()));
}
preferences:
38.95 ms | 402 KiB | 5 Q