1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

Revisione modulo Stato dei servizi

Miglioramento gestione moduli e widget, introduzione alla gestione dei plugin. Revisione della schermata di informazioni sui servizi attivi.
This commit is contained in:
Dasc3er
2021-09-03 20:14:30 +02:00
parent 8e721ae142
commit b4af4d98dd
8 changed files with 1124 additions and 356 deletions

View File

@@ -567,3 +567,35 @@ if (!function_exists('temp_file')) {
return $file;
}
}
if (!function_exists('adjustBrightness')) {
/**
* Increases or decreases the brightness of a color by a percentage of the current brightness.
*
* @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
* @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
*
* @return string
*
* @author maliayas
*/
function adjustBrightness($hexCode, $adjustPercent)
{
$hexCode = ltrim($hexCode, '#');
if (strlen($hexCode) == 3) {
$hexCode = $hexCode[0].$hexCode[0].$hexCode[1].$hexCode[1].$hexCode[2].$hexCode[2];
}
$hexCode = array_map('hexdec', str_split($hexCode, 2));
foreach ($hexCode as &$color) {
$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
$adjustAmount = ceil($adjustableLimit * $adjustPercent);
$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
}
return '#'.implode($hexCode);
}
}