Esempio n. 1
0
 /**
  * Export question areas.
  *
  * @param Coords $coords
  *
  * @return \stdClass
  */
 private function exportArea(Coords $coords)
 {
     $exportData = new \stdClass();
     $exportData->id = $coords->getId();
     $exportData->color = $coords->getColor();
     $position = explode(',', $coords->getValue());
     switch ($coords->getShape()) {
         case 'circle':
             $exportData->shape = 'circle';
             $exportData->radius = $coords->getSize() / 2;
             // We store the top left corner, so we need to calculate the real center
             $center = $this->exportCoords($position);
             $center->x += $exportData->radius;
             $center->y += $exportData->radius;
             $exportData->center = $center;
             break;
         case 'square':
             $exportData->shape = 'rect';
             $exportData->coords = [$this->exportCoords($position), $this->exportCoords([$position[0] + $coords->getSize(), $position[1] + $coords->getSize()])];
             break;
     }
     return $exportData;
 }