Die Transformung von CMYK zu RGB erfolgt über HSV.

This commit is contained in:
2021-03-04 11:30:17 +01:00
parent 336c9c63da
commit 58c0f5f717
3 changed files with 58 additions and 15 deletions
@@ -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
{
}
}