Exemple #1
0
 public function operate($op, $other)
 {
     $result = array();
     if (!$other instanceof \Less\Node\Color) {
         $other = $other->toColor();
     }
     for ($c = 0; $c < 3; $c++) {
         $result[$c] = \Less\Environment::operate($op, $this->rgb[$c], $other->rgb[$c]);
     }
     return new \Less\Node\Color($result, $this->alpha + $other->alpha);
 }
Exemple #2
0
 public function compile($env)
 {
     $name = $this->name;
     if (strpos($name, '@@') === 0) {
         $v = new \Less\Node\Variable(substr($name, 1), $this->index + 1);
         $name = '@' . $v->compile($env)->value;
     }
     $callback = function ($frame) use ($env, $name) {
         if ($v = $frame->variable($name)) {
             return $v->value->compile($env);
         }
     };
     if ($variable = \Less\Environment::find($env->frames, $callback)) {
         return $variable;
     } else {
         throw new \Less\Exception\CompilerException("variable " . $name . " is undefined", $this->index);
     }
 }
 public function rgba($r, $g, $b, $a)
 {
     $rgb = array_map(function ($c) {
         return \Less\Environment::number($c);
     }, array($r, $g, $b));
     $a = self::number($a);
     return new \Less\Node\Color($rgb, $a);
 }
 public function operate($op, $other)
 {
     return new \Less\Node\Dimension(\Less\Environment::operate($op, $this->value, $other->value), $this->unit ?: $other->unit);
 }