Esempio n. 1
0
 public function luminance($color = null)
 {
     if (!$color instanceof Less_Tree_Color) {
         throw new Less_Exception_Compiler('The first argument to luminance must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : ''));
     }
     $luminance = 0.2126 * $color->rgb[0] / 255 + 0.7151999999999999 * $color->rgb[1] / 255 + 0.0722 * $color->rgb[2] / 255;
     return new Less_Tree_Dimension(Less_Parser::round($luminance * $color->alpha * 100), '%');
 }
 public function toHex($v)
 {
     $ret = '#';
     foreach ($v as $c) {
         $c = Less_Functions::clamp(Less_Parser::round($c), 255);
         if ($c < 16) {
             $ret .= '0';
         }
         $ret .= dechex($c);
     }
     return $ret;
 }
Esempio n. 3
0
 public function luminance($color)
 {
     $luminance = 0.2126 * $color->rgb[0] / 255 + 0.7151999999999999 * $color->rgb[1] / 255 + 0.0722 * $color->rgb[2] / 255;
     return new Less_Tree_Dimension(Less_Parser::round($luminance * $color->alpha * 100), '%');
 }
Esempio n. 4
0
 public function toARGB()
 {
     $argb = array_merge((array) Less_Parser::round($this->alpha * 255), $this->rgb);
     $temp = '';
     foreach ($argb as $i) {
         $i = Less_Parser::round($i);
         $i = dechex($i > 255 ? 255 : ($i < 0 ? 0 : $i));
         $temp .= str_pad($i, 2, '0', STR_PAD_LEFT);
     }
     return '#' . $temp;
 }
Esempio n. 5
0
 public function luma($color)
 {
     return new Less_Tree_Dimension(Less_Parser::round($color->luma() * $color->alpha * 100), '%');
 }
 public function toARGB()
 {
     $argb = array_merge((array) Less_Parser::round($this->alpha * 255), $this->rgb);
     return $this->toHex($argb);
 }