/**
  * Draws the layers content on the image
  * @param zibo\library\image\Image $image The image to draw upon
  * @param zibo\library\diagram\Diagram $diagram The diagram we're drawing
  * @return null
  */
 public function draw(Image $image, Diagram $diagram)
 {
     $grid = $diagram->getGrid();
     $margin = $diagram->getMargin();
     $cellDimension = $grid->getCellDimension();
     $cellWidth = $cellDimension->getWidth();
     $cellHeight = $cellDimension->getHeight();
     $gridDimension = $grid->getGridDimension();
     $gridWidth = $gridDimension->getWidth();
     $gridHeight = $gridDimension->getHeight();
     for ($x = 0; $x <= $gridWidth; $x++) {
         for ($y = 0; $y <= $gridHeight; $y++) {
             if ($grid->isFree(new Point($x, $y))) {
                 continue;
             }
             $pointX = $x * $cellWidth + $margin;
             $pointY = $y * $cellHeight + $margin;
             $point = new Point($pointX, $pointY);
             $image->fillRectangle($point, $cellDimension, $this->color);
         }
     }
 }
예제 #2
0
 /**
  * Creates the image needed to draw the layers out of the grid
  * @return zibo\library\image\Image
  */
 private function createImage()
 {
     $gridDimension = $this->grid->getGridDimension();
     $cellDimension = $this->grid->getCellDimension();
     $margin = 2 * $this->margin;
     $width = $gridDimension->getWidth() * $cellDimension->getWidth() + $margin;
     $height = $gridDimension->getHeight() * $cellDimension->getHeight() + $margin;
     $image = new Image(null, $width, $height);
     $image->fillRectangle(new Point(0, 0), new Dimension($width, $height), $this->backgroundColor);
     return $image;
 }