private function generateImage()
{
$this->generatedImage = new \Imagick();
$rgbBackgroundColor = $this->getBackgroundColor();
if (null === $rgbBackgroundColor) {
$background = 'none';
} else {
$background = new ImagickPixel("rgb({$rgbBackgroundColor['0']},{$rgbBackgroundColor['1']},{$rgbBackgroundColor['2']})");
}
$this->generatedImage->newImage($this->pixelRatio * 5, $this->pixelRatio * 5, $background, 'png');
// prepare color
$rgbColor = $this->getColor();
$color = new ImagickPixel("rgb({$rgbColor['0']},{$rgbColor['1']},{$rgbColor['2']})");
$draw = new ImagickDraw();
$draw->setFillColor($color);
// draw the content
foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
foreach ($lineValue as $colKey => $colValue) {
if (true === $colValue) {
$draw->rectangle($colKey * $this->pixelRatio, $lineKey * $this->pixelRatio, ($colKey + 1) * $this->pixelRatio, ($lineKey + 1) * $this->pixelRatio);
}
}
}
$this->generatedImage->drawImage($draw);
return $this;
}