- Issue created by @gugalamaciek
When I color with (new ColorRB(...))->toHex(), the opacity value is lost. It's because incorrect value is passed to ColorHex() constructor inside ColorRGB::toHex().
$color = (new ColorRGB(255,0,0,0.5))->toHex()
When you call $color->getOpacity(), it returns 0 instead of expected 0.5.
Fix ColorRGB::toHex() by replacing:
return new ColorHex(
$this->intToColorHex($this->getRed()) . $this->intToColorHex($this->getGreen()) . $this->intToColorHex($this->getBlue()),
(float) $this->intToColorHex((int) $this->getOpacity() * 255)
);with:
return new ColorHex(
$this->intToColorHex($this->getRed()) . $this->intToColorHex($this->getGreen()) . $this->intToColorHex($this->getBlue()),
$this->getOpacity()
);Active
3.0
Code