|
@ -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; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|