Same filename and directory in other branches
- 8.x-2.x src/ColorCMYK.php
Namespace
Drupal\color_field
File
-
src/ColorCMYK.php
View source
<?php
declare (strict_types=1);
namespace Drupal\color_field;
class ColorCMYK extends ColorCMY {
protected int $key;
public function __construct(int $cyan, int $magenta, int $yellow, int $key, float $opacity) {
parent::__construct($cyan, $magenta, $yellow, $opacity);
$this->key = $key;
}
public function getKey() : int {
return $this->key;
}
public function toRgb() : ColorRGB {
return $this->toCmy()
->toRgb();
}
public function toCmy() : ColorCMY {
$cyan = $this->cyan * (1 - $this->key) + $this->key;
$magenta = $this->magenta * (1 - $this->key) + $this->key;
$yellow = $this->yellow * (1 - $this->key) + $this->key;
return new ColorCMY($cyan, $magenta, $yellow, $this->getOpacity());
}
public function toHsl() : ColorHSL {
return $this->toRgb()
->toHsl();
}
}
Classes
| Title |
Deprecated |
Summary |
| ColorCMYK |
|
ColorCMYK represents the CMYK color format. |