From 6409ecfa03f92f3e5e168dcbdef019c127f1c3e4 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Thu, 13 Jul 2023 11:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B2=E6=9F=93=E6=B5=8B=E5=BC=8F=20?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/MatHelper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/MatHelper.php b/src/utils/MatHelper.php index cae69b2..69c5b57 100644 --- a/src/utils/MatHelper.php +++ b/src/utils/MatHelper.php @@ -24,12 +24,12 @@ class MatHelper{ /** * 十六进制颜色 转换为 浮点数颜色 */ - static function hex2floatColor($hexColor, $scale = 1){ + static function hex2floatColor($hexColor, $scale = 1, $gamma = 2.2){ $floatColor = ''; $hexColor = trim($hexColor); - $r = (hexdec(substr($hexColor, 1, 2))/255) ** 2.2 * $scale; - $g = (hexdec(substr($hexColor, 3, 2))/255) ** 2.2 * $scale; - $b = (hexdec(substr($hexColor, 5, 2))/255) ** 2.2 * $scale; + $r = (hexdec(substr($hexColor, 1, 2))/255 * $scale) ** $gamma; + $g = (hexdec(substr($hexColor, 3, 2))/255 * $scale) ** $gamma; + $b = (hexdec(substr($hexColor, 5, 2))/255 * $scale) ** $gamma; $floatColor = "$r $g $b"; return $floatColor; }