/** * @access public * @static * @author Laurent Laville <*****@*****.**> */ function color2RGB($color) { $c = array(); if ($color[0] == '#') { $c = Image_Color::hex2rgb($color); } else { $c = Image_Color::namedColor2RGB($color); } return $c; }
function testHex2rgb_WithoutPound() { $result = Image_Color::hex2rgb('abcdef'); $this->assertEquals(array(171, 205, 239, 'hex' => 'abcdef'), $result); }
/** * getRange * Given a degree, you can get the range of colors between one color and * another color. * * @param string $degrees How much each 'step' between the colors we should take. * * @return array Array of all the colors, one element for each color. * @access public */ function getRange($degrees) { $tempColors = parent::getRange($degrees); // now add alpha-channel information $steps = count($tempColors); for ($counter = 0; $counter < $steps; $counter++) { $tempColors[$counter] = parent::hex2rgb($tempColors[$counter]); unset($tempColors[$counter]['hex']); $tempColors[$counter][3] = (int) round(((double) $this->color1[3] * ($steps - $counter) + (double) $this->color2[3] * $counter) / $steps); } return $tempColors; }
/** * hsv2rgb * Converts a HSV (Hue, Saturation, Brightness) value to RGB. * * @access public * @param integer $h Hue * @param integer $s Saturation * @param integer $v Brightness * @return string The RGB value. * @author Jason Lotito <*****@*****.**> */ function hsv2rgb($h, $s, $v) { return Image_Color::hex2rgb(Image_Color::hsv2hex($h, $s, $v)); }