Die Transformung von CMYK zu RGB erfolgt über HSV.
This commit is contained in:
@@ -24,19 +24,8 @@ class CyanMagentaYellowKeyTransformer implements ColorModelTransformInterface
|
||||
|
||||
public function toRedGreenBlue(): RedGreenBlue
|
||||
{
|
||||
$cyan = $this->color->getCyan();
|
||||
$magenta = $this->color->getMagenta();
|
||||
$yellow = $this->color->getYellow();
|
||||
$key = $this->color->getKey();
|
||||
|
||||
$red = 0;
|
||||
$green = 0;
|
||||
$blue = 0;
|
||||
|
||||
return (new RedGreenBlue())
|
||||
->setRed($red)
|
||||
->setGreen($green)
|
||||
->setBlue($blue);
|
||||
$hsv_color = (new Utilities\CyanMagentaYellowKeyToHueSaturationValue($this->color))->convert();
|
||||
return (new Utilities\HueSaturationValueToRedGreenBlue($hsv_color))->convert();
|
||||
}
|
||||
|
||||
public function toCyanMagentaYellowKey(): CyanMagentaYellowKey
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TorstenHettstedt\Colors\Transformer\Utilities;
|
||||
|
||||
|
||||
use TorstenHettstedt\Colors\ColorModels\HueSaturationValue;
|
||||
use TorstenHettstedt\Colors\ColorModels\RedGreenBlue;
|
||||
|
||||
class HueSaturationValueToRedGreenBlue
|
||||
{
|
||||
// Daten für HSV
|
||||
/** @var float : Definition des Farbton als Anteil eines Vollkreises '$Hue * π' */
|
||||
protected float $hue;
|
||||
/** @var float : Definition der Sättigung der Farbe */
|
||||
protected float $saturation;
|
||||
/** @var float : Definition der Helligkeit der Farbe */
|
||||
protected float $value;
|
||||
|
||||
// Daten für RGB
|
||||
/** @var float : Definition des Rotanteil */
|
||||
protected float $red = 1.0;
|
||||
/** @var float : Definition des Grünanteil */
|
||||
protected float $green = 1.0;
|
||||
/** @var float : Definition des Blauanteil */
|
||||
protected float $blu = 1.0;
|
||||
|
||||
/**
|
||||
* HueSaturationValueToRedGreenBlue constructor.
|
||||
* @param HueSaturationValue $from_color
|
||||
* @noinspection PhpPureAttributeCanBeAddedInspection
|
||||
*/
|
||||
public function __construct(HueSaturationValue $from_color)
|
||||
{
|
||||
$this->hue = $from_color->getHue();
|
||||
$this->saturation = $from_color->getSaturation();
|
||||
$this->value = $from_color->getValue();
|
||||
}
|
||||
|
||||
public function convert(): RedGreenBlue
|
||||
{
|
||||
$this->processConvert();
|
||||
|
||||
return (new RedGreenBlue())
|
||||
->setRed($this->red)
|
||||
->setGreen($this->green)
|
||||
->setBlue($this->blu);
|
||||
}
|
||||
|
||||
|
||||
protected function processConvert(): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -222,8 +222,6 @@ class CyanMagentaYellowKeyTransformerTest extends Unit
|
||||
*/
|
||||
public function testToRedGreenBlue(array $cmyk, array $rgb)
|
||||
{
|
||||
$this->markTestSkipped('Das Verhalten muss über HSL erforscht werden.');
|
||||
|
||||
$this->color = $this->make(CyanMagentaYellowKey::class, $cmyk);
|
||||
|
||||
$transformer = new CyanMagentaYellowKeyTransformer($this->color);
|
||||
|
||||
Reference in New Issue
Block a user