$yb){
$l = $l - $yb;
$r = ($r * ($yb - $l) + 255 * $l) / $yb;
$g = ($g * ($yb - $l) + 255 * $l) / $yb;
$b = ($b * ($yb - $l) + 255 * $l) / $yb;
}else{
$r = ($r * $l) / $yb;
$g = ($g * $l) / $yb;
$b = ($b * $l) / $yb;
}
$nr=$this->tohex($r);
$ng=$this->tohex($g);
$nb=$this->tohex($b);
return '#'.$nr.$ng.$nb;
}
private function tohex($n)
{
$hexch = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
$n = round($n);
$l = $n % 16;
$h = floor(($n / 16)) % 16;
return ''.$hexch[$h].''.$hexch[$l].'';
}
/**
* 获取颜色值
*/
public function colorTorgb($color)
{
if(!empty($color)&&(strlen($color)==7)){
$r=hexdec(substr($color,1,2));
$g=hexdec(substr($color,3,2));
$b=hexdec(substr($color,5));
}else{
$r=$g=$b='00';
}
return array($r, $g, $b);
}
/**
* 获取样式的
*/
public function getApptheme($nohui=true, $ism=false)
{
$arr = $this->getColor();
$color = $arr['color'];
$colors = $arr['colors'];
$colora = $arr['colora'];
$bodybgcolor = 'rgba('.$colors.',0.03)';
$hgcolor = 'rgba('.$colors.',0.15)';
$vgcolor = 'rgba('.$colors.',0.1)';
$str[] = '';
$str[] = '';
$path = 'webmain/css/rockmy.css';
if(file_exists($path))$str[] = '';
$str[] = '';
return join(PHP_EOL, $str);
}
/**
* 获取样式
*/
public function getColor()
{
$color = $this->getTheme();
$maincolora = $this->colorTorgb($color);
$colors = ''.$maincolora[0].','.$maincolora[1].','.$maincolora[2].'';
return array(
'color' => $color,
'colors' => $colors,
'colora' => $maincolora,
);
}
/**
* 获取对应颜色
*/
public function getTheme()
{
$color = getconfig('apptheme','#1389D3');
//$apptheme = $this->rock->get('apptheme');
//if(strlen($apptheme)==6)$this->rock->savecookie('apptheme', $apptheme);
//if(!$apptheme)$apptheme = $this->rock->cookie('apptheme');
//if(strlen($apptheme)==6)$color = '#'.$apptheme.'';
return $color;
}
}