예제 #1
0
파일: Color.php 프로젝트: ju1ius/css-parser
 public function fromRgb(array $rgb)
 {
     $mode = 'rgb';
     foreach ($rgb as $channel => $value) {
         if ($channel === 'a') {
             $value = Util\Color::constrainValue((string) $value, 0, 1);
             if ($value === 1) {
                 continue;
             }
             $mode .= 'a';
         } else {
             $value = Util\Color::normalizeRgbValue((string) $value);
         }
         $this->channels[$channel] = new Dimension($value);
     }
     $this->mode = $mode;
     return $this;
 }