An interesting idea. Wonder if it's been done before.
HSV (or HSL) would be easiest for the initial math, but the numbers would probably have to be
converted to RGB.
That January's blue is HSV 240,100%,100%. The H increases and wraps around 360->0 until getting back to 240. The equation to calculate the H according to the day of the year would be
Code: Select all
H(start, dayofyear, daysinyear) = (start + 360 * (dayofyear - 1) / daysinyear) mod 360
PHPized would be
Code: Select all
$H = fmod($start + 360 * date("z") / (365 + date("L")), 360.0);
S and V would be fixed according to whether you wanted a highlight, shadow, midtone, etc.
While I'm at it,
Code: Select all
function hsv2rgb($h, $s, $v) {
$c = $v * $s;
$h1 = fmod($h, 360.0) / 60;
$x = $c * (1 - abs(fmod($h1, 2.0) - 1));
$m = $v - $c;
$lookup = array(
array($c, $x, 0),
array($x, $c, 0),
array(0, $c, $x),
array(0, $x, $c),
array($x, 0, $c),
array($c, 0, $x)
);
list($r, $g, $b) = $lookup[floor($h1)];
$r = round(255 * ($r + $m)); $g = round(255 * ($g + $m)); $b = round(255 * ($b + $m));
return array(
0 => ($r << 16) + ($g << 8) + $b,
"r" => $r, "g" => $g, "b" => $b,
"hex" => sprintf("%02X%02X%02X", $r, $g, $b),
"rgb" => sprintf("rgb(%u, %u, %u)", $r, $g, $b)
);
}
Oct 11's color is
this light greenish/blueish color, which matches up with the chart you posted.