Pop\Color\Convert::toRgb PHP Метод

toRgb() публичный статический Метод

Method to convert a color space object to an integer RGB object
public static toRgb ( Pop\Color\Space\ColorInterface $color ) : Rgb
$color Pop\Color\Space\ColorInterface
Результат Pop\Color\Space\Rgb
    public static function toRgb(Space\ColorInterface $color)
    {
        $class = get_class($color);
        if ($class == 'Pop\\Color\\Space\\Rgb') {
            throw new Exception('That color space object is already that type.');
        }
        $type = strtolower(substr($class, strrpos($class, '\\') + 1));
        $method = $type . 'ToRgb';
        return self::$method($color);
    }

Usage Example

Пример #1
0
 public function testLabToRgb()
 {
     $rgb = Convert::toRgb(new Lab(100, 100, 100));
     $this->assertInstanceOf('Pop\\Color\\Space\\Rgb', $rgb);
     $this->assertEquals('195,146,49', (string) $rgb);
 }