Pop\Color\Convert::toHsb PHP Method

toHsb() public static method

Method to convert a color space object to an HSB object
public static toHsb ( Pop\Color\Space\ColorInterface $color ) : Hsb
$color Pop\Color\Space\ColorInterface
return Pop\Color\Space\Hsb
    public static function toHsb(Space\ColorInterface $color)
    {
        $class = get_class($color);
        if ($class == 'Pop\\Color\\Space\\Hsb') {
            throw new Exception('That color space object is already that type.');
        }
        $type = strtolower(substr($class, strrpos($class, '\\') + 1));
        $method = $type . 'ToHsb';
        return self::$method($color);
    }

Usage Example

Example #1
0
 public function testLabToHsb()
 {
     $hsb = Convert::toHsb(new Lab(100, 100, 100));
     $this->assertInstanceOf('Pop\\Color\\Space\\Hsb', $hsb);
     $this->assertEquals('40,75,76', (string) $hsb);
 }