/** * Returns the 'value' channel of @color in the HSV space * * @param ILess_Node_Color $color * @return string */ public function hsvvalue(ILess_Node $color) { if (!$color instanceof ILess_Node_Color) { return $color; } $hsv = $color->toHSV(); return new ILess_Node_Dimension(ILess_Math::round($hsv['v'] * 100), '%'); }
/** * 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; }
/** * 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)), '%'); }
/** * @covers round * @dataProvider getDataForRoundTest */ public function testRound($value, $precision, $expected) { $this->assertEquals($expected, ILess_Math::round($value, $precision), sprintf('Rounding of "%s" with precision "%s" works', $value, $precision)); }