/** * Returns the faded color for the given color. * * @param $color * @param $percentage * @return the faded color */ function getFadedColor($color, $percentage = 85) { $percentage = 100 - $percentage; $rgbValues = array_map('hexDec', GCalendarUtil::str_split(ltrim($color, '#'), 2)); for ($i = 0, $len = count($rgbValues); $i < $len; $i++) { $rgbValues[$i] = decHex(floor($rgbValues[$i] + (255 - $rgbValues[$i]) * ($percentage / 100))); } return '#' . implode('', $rgbValues); }