コード例 #1
0
 public function createRaster(ImageResource $resource)
 {
     if ($this->isPercentage) {
         $this->calculatePercentage($resource);
     }
     $raster = new ImageRaster();
     $segment = new Segment($resource->getWidth() - $this->width / 2, $resource->getHeight() - $this->height / 2, $this->width, $this->height);
     $raster->addSegment($segment);
     return $raster;
 }
コード例 #2
0
 public function createRaster(ImageResource $resource)
 {
     if ($this->isPercentage) {
         $this->calculatePercentage($resource);
     }
     $raster = new ImageRaster();
     $x = $y = 0;
     while ($x <= $resource->getWidth() && $y <= $resource->getHeight()) {
         $segment = new Segment($x, $y, min(array($this->width, $resource->getWidth() - $x)), min(array($this->height, $resource->getHeight() - $y)));
         $raster->addSegment($segment);
         // new row
         if ($x + $this->width >= $resource->getWidth()) {
             $x = 0;
             $y += $this->height;
         } else {
             $x += $this->width;
         }
         if ($y >= $resource->getHeight()) {
             return $raster;
         }
     }
     return $raster;
 }