Browse Source

渲染测式 开发

master
yuanjiajia 1 year ago
parent
commit
6409ecfa03
  1. 8
      src/utils/MatHelper.php

8
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 = ''; $floatColor = '';
$hexColor = trim($hexColor); $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"; $floatColor = "$r $g $b";
return $floatColor; return $floatColor;
} }

Loading…
Cancel
Save