Pop\Image\Gd::setColor PHP Method

setColor() protected method

Set and return a color identifier.
protected setColor ( Pop\Color\Space\ColorInterface $color = null ) : mixed
$color Pop\Color\Space\ColorInterface
return mixed
    protected function setColor(ColorInterface $color = null)
    {
        if (null === $this->resource) {
            throw new Exception('Error: The image resource has not been created.');
        }
        $opac = null === $this->opacity ? 0 : $this->opacity;
        if (null !== $color) {
            $color = imagecolorallocatealpha($this->resource, (int) $color->getRed(), (int) $color->getGreen(), (int) $color->getBlue(), $opac);
        } else {
            $color = imagecolorallocatealpha($this->resource, 0, 0, 0, $opac);
        }
        return $color;
    }