Pop\Color\Convert::toCmyk PHP Method

toCmyk() public static method

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

Usage Example

Example #1
0
<?php

require_once '../../bootstrap.php';
use Pop\Color;
try {
    $rgb = new Color\Space\Rgb(112, 124, 228);
    $cmyk = Color\Convert::toCmyk($rgb);
    echo 'RGB: ' . $rgb . ' => CMYK: ' . $cmyk;
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL . PHP_EOL;
}
All Usage Examples Of Pop\Color\Convert::toCmyk