From 02fe9501092d1b35c3b54086af0d5937a6d0c6fd Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Thu, 20 Jul 2023 08:56:48 +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 --- composer.json | 2 +- src/utils/MatHelper.php | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index ca734b3..93da945 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,6 @@ "minimum-stability": "dev", "require": { "guzzlehttp/guzzle": "~6.0", - "spatie/color": "dev-main" + "ozdemirburak/iris": "dev-master" } } diff --git a/src/utils/MatHelper.php b/src/utils/MatHelper.php index 8fb9268..0bdd6ef 100644 --- a/src/utils/MatHelper.php +++ b/src/utils/MatHelper.php @@ -12,8 +12,9 @@ use Blobt\Luxcore\scene\texture\transform\NormalMap; use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; use Imagick; -use Spatie\Color\Factory; -use Spatie\Color\Hsb; +use OzdemirBurak\Iris\Color\Factory; +use OzdemirBurak\Iris\Color\Hsv; + class MatHelper{ @@ -30,7 +31,7 @@ class MatHelper{ */ static function hex2floatColor($hexColor, $scale = 1, $gamma = self::COLOR_SPACE_SRGB){ // 十六进制颜色 转 RGB色 - $color = Factory::fromString(trim($hexColor)); + $color = Factory::init(trim($hexColor)); $color = $color->toRgb(); // RGB色 转 浮点数RGB颜色 @@ -46,16 +47,17 @@ class MatHelper{ * 获得 十六进制颜色 同色调 的 最大亮度 */ static function colorMaxBrightness($hexColor,$scale = 1){ - // 十六进制颜色 转 HSB色 - $color = Factory::fromString($hexColor); - $color = $color->toHsb(); + // 十六进制颜色 转 HSV色 + $color = Factory::init(trim($hexColor)); + $color = $color->toHsv(); // 亮度提升 - $currentBri = $color->brightness(); - $gain =$currentBri + (100-$currentBri) * $scale; - $color = new Hsb($color->hue(), $color->saturation(), $gain); + $currentBri = $color->value(); + $gain =round($currentBri + (100-$currentBri) * $scale); + $color = new Hsv("hsv({$color->hue()},{$color->saturation()}%,{$gain}%)"); - return $color->toHex(); + $hexColor = trim($color->toHex()); + return $hexColor; }