Browse Source

渲染测式 开发

master
yuanjiajia 1 year ago
parent
commit
02fe950109
  1. 2
      composer.json
  2. 22
      src/utils/MatHelper.php

2
composer.json

@ -17,6 +17,6 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"require": { "require": {
"guzzlehttp/guzzle": "~6.0", "guzzlehttp/guzzle": "~6.0",
"spatie/color": "dev-main"
"ozdemirburak/iris": "dev-master"
} }
} }

22
src/utils/MatHelper.php

@ -12,8 +12,9 @@ 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;
use OzdemirBurak\Iris\Color\Factory;
use OzdemirBurak\Iris\Color\Hsv;
class MatHelper{ class MatHelper{
@ -30,7 +31,7 @@ class MatHelper{
*/ */
static function hex2floatColor($hexColor, $scale = 1, $gamma = self::COLOR_SPACE_SRGB){ static function hex2floatColor($hexColor, $scale = 1, $gamma = self::COLOR_SPACE_SRGB){
// 十六进制颜色 转 RGB色 // 十六进制颜色 转 RGB色
$color = Factory::fromString(trim($hexColor));
$color = Factory::init(trim($hexColor));
$color = $color->toRgb(); $color = $color->toRgb();
// RGB色 转 浮点数RGB颜色 // RGB色 转 浮点数RGB颜色
@ -46,16 +47,17 @@ class MatHelper{
* 获得 十六进制颜色 同色调 最大亮度 * 获得 十六进制颜色 同色调 最大亮度
*/ */
static function colorMaxBrightness($hexColor,$scale = 1){ 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;
} }

Loading…
Cancel
Save