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;
}