Browse Source

渲染测式 开发

master
yuanjiajia 1 year ago
parent
commit
a24d093441
  1. 23
      src/utils/MatHelper.php

23
src/utils/MatHelper.php

@ -12,6 +12,8 @@ use Blobt\Luxcore\scene\texture\transform\NormalMap;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions; use GuzzleHttp\RequestOptions;
use Imagick; use Imagick;
use Spatie\Color\Factory;
use Spatie\Color\Hsb;
class MatHelper{ class MatHelper{
@ -38,21 +40,16 @@ class MatHelper{
* 获得 十六进制颜色 同色调 最大亮度 * 获得 十六进制颜色 同色调 最大亮度
*/ */
static function colorMaxBrightness($hexColor,$scale){ static function colorMaxBrightness($hexColor,$scale){
$r = (hexdec(substr($hexColor, 1, 2)));
$g = (hexdec(substr($hexColor, 3, 2)));
$b = (hexdec(substr($hexColor, 5, 2)));
// 十六进制颜色 转 HSB色
$color = Factory::fromString($hexColor);
$color = $color->toHsb();
$MaxBrightnessPass = 0;
foreach([$r, $g, $b] as $value){
$MaxBrightnessPass = $value > $MaxBrightnessPass ? $value : $MaxBrightnessPass;
}
$gain = (255 - $MaxBrightnessPass) / 255 * $scale;
$r =dechex(round($r + 255 * $gain));
$g =dechex(round($g + 255 * $gain));
$b =dechex(round($b + 255 * $gain));
// 亮度提升
$currentBri = $color->brightness();
$gain =$currentBri + (100-$currentBri) * $scale;
$color = new Hsb($color->hue(), $color->saturation(), $gain);
return "#{$r}{$g}{$b}";
return $color->toHex();
} }

Loading…
Cancel
Save