Theming of Cachet is much simpler with more color settings
This commit is contained in:
@@ -67,3 +67,31 @@ if (!function_exists('subscribers_enabled')) {
|
||||
return $isEnabled && $mailAddress && $mailFrom;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('color_darken')) {
|
||||
/**
|
||||
* Darken a color.
|
||||
*
|
||||
* @param string $hex
|
||||
* @param int $percent
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function color_darken($hex, $percent)
|
||||
{
|
||||
$hex = preg_replace('/[^0-9a-f]/i', '', $hex);
|
||||
$new_hex = '#';
|
||||
|
||||
if (strlen($hex) < 6) {
|
||||
$hex = $hex[0] + $hex[0] + $hex[1] + $hex[1] + $hex[2] + $hex[2];
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$dec = hexdec(substr($hex, $i * 2, 2));
|
||||
$dec = min(max(0, $dec + $dec * $percent), 255);
|
||||
$new_hex .= str_pad(dechex($dec), 2, 0, STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
return $new_hex;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user