diff --git a/src/Color/Color.php b/src/Color/Color.php index 26d9c4a..7426225 100644 --- a/src/Color/Color.php +++ b/src/Color/Color.php @@ -44,6 +44,11 @@ public function getOpacity(): float return 1 - $this->alpha / 127; } + public function getHex(): string + { + return sprintf('#%02x%02x%02x', $this->red, $this->green, $this->blue); + } + public function toArray(): array { return [ diff --git a/src/Color/ColorInterface.php b/src/Color/ColorInterface.php index 91d3818..398be26 100644 --- a/src/Color/ColorInterface.php +++ b/src/Color/ColorInterface.php @@ -16,6 +16,8 @@ public function getAlpha(): int; public function getOpacity(): float; + public function getHex(): string; + /** @return array */ public function toArray(): array; }