/** * Returns the luma * * @param boolean $raw Return raw value? * @return mixed ILess_Node_Dimension if $raw is false */ public function getLuma($raw = false) { return $raw ? $this->color->getLuma() : new ILess_Node_Dimension(ILess_Math::clean(ILess_Math::multiply(ILess_Math::round(ILess_Math::multiply($this->color->getLuma(), $this->color->getAlpha()), 2), 100)), '%'); }
/** * Converts the $number to "real" number * * @param ILess_Node_Dimension|integer|float $number * @return double * @throws InvalidArgumentException */ public function number($number) { if ($number instanceof ILess_Node_Dimension) { return $number->unit->is('%') ? ILess_Math::clean(ILess_Math::divide($number->value, '100')) : $number->value; } elseif (is_numeric($number)) { return $number; } else { throw new InvalidArgumentException(sprintf('Color functions take numbers as parameters. "%s" given.', gettype($number))); } }
/** * Returns the string representation in ARGB model * * @return string */ public function toARGB() { $argb = array_merge(array(ILess_Math::clean(ILess_Math::round($this->alpha * 256))), $this->rgb); $result = ''; foreach ($argb as $i) { $i = ILess_Math::round($i); $i = dechex($i > 255 ? 255 : ($i < 0 ? 0 : $i)); $result .= str_pad($i, 2, '0', STR_PAD_LEFT); } return '#' . $result; }