Exemple #1
0
 /**
  * Return file name through a promise.
  *
  * @param integer $xAxis X coordinate.
  * @param integer $yAxis Y coordinate.
  *
  * @return \React\Promise\Promise
  */
 public function getTile($xAxis, $yAxis)
 {
     $fileName = str_replace(['{x}', '{y}'], [$xAxis, $yAxis], $this->location);
     $deferred = new Deferred();
     $this->loader->imageExists($fileName)->then(function () use($deferred, $fileName) {
         $deferred->resolve($fileName);
     }, function () use($deferred, $fileName) {
         if (empty($this->fallbackImage)) {
             return $deferred->resolve($fileName);
         }
         $deferred->resolve($this->fallbackImage);
     });
     return $deferred->promise();
 }
Exemple #2
0
 /**
  * Draw a blip on the image.
  *
  * @param Blip $blip Blip to draw on the map.
  *
  * @return void
  */
 protected function drawBlip(Blip $blip)
 {
     $this->loader->addImage($blip->getImage())->then(function ($image) use($blip) {
         $this->drawImage($image, $blip->calculatePosition($this->centerPoint, $this->size, $this->zoom));
     });
 }