mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-07 21:18:39 +00:00
Optimize color
This commit is contained in:
parent
a65f388603
commit
ad296d4b04
|
|
@ -44,15 +44,10 @@ class ColorUtils
|
||||||
$diff = [];
|
$diff = [];
|
||||||
$gradient = [];
|
$gradient = [];
|
||||||
|
|
||||||
if ($value <= $stop[0]) {
|
if ($value <= $stop[0] && $value < $start[0]) {
|
||||||
if ($value < $start[0]) {
|
$value = $start[0];
|
||||||
$value = $start[0];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ($value > $end[0]) {
|
$value = min($value, $end[0]);
|
||||||
$value = $end[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$start = $stop;
|
$start = $stop;
|
||||||
$stop = $end;
|
$stop = $end;
|
||||||
}
|
}
|
||||||
|
|
@ -67,13 +62,7 @@ class ColorUtils
|
||||||
$gradient['b'] = $start[3] + ($value - $start[0]) / ($diff[0]) * $diff[3];
|
$gradient['b'] = $start[3] + ($value - $start[0]) / ($diff[0]) * $diff[3];
|
||||||
|
|
||||||
foreach ($gradient as &$color) {
|
foreach ($gradient as &$color) {
|
||||||
if ($color > 255) {
|
$color = max(min($color, 255), 0);
|
||||||
$color = 255;
|
|
||||||
} elseif ($color < 0) {
|
|
||||||
$color = 0;
|
|
||||||
} else {
|
|
||||||
$color = (int) $color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $gradient;
|
return $gradient;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user