/** * make map work copy of image * * @param int $a_area_nr draw area $a_area_nr only * @param boolean $a_exclude true: draw all areas but area $a_area_nr */ function makeMapWorkCopy($a_st_item, $a_area_nr = 0, $a_exclude = false, $a_output_new_area, $a_area_type, $a_coords) { global $lng; if (!$a_st_item->copyOriginal()) { return false; } $a_st_item->buildMapWorkImage(); // determine ratios (first see whether the instance has w/h defined) $width = $this->getWidth(); $height = $this->getHeight(); // if instance has no size, use object w/h if ($width == 0 && $height == 0) { $width = $a_st_item->getWidth(); $height = $a_st_item->getHeight(); } $size = @getimagesize($a_st_item->getMapWorkCopyName()); $x_ratio = 1; if ($size[0] > 0 && $width > 0) { $x_ratio = $width / $size[0]; } $y_ratio = 1; if ($size[1] > 0 && $height > 0) { $y_ratio = $height / $size[1]; } // draw map areas $areas = $this->getMapAreas(); for ($i = 0; $i < count($areas); $i++) { if ($i + 1 == $a_area_nr && !$a_exclude || $i + 1 != $a_area_nr && $a_exclude || $a_area_nr == 0) { $area = new ilMapArea(); $area->setShape($areas[$i]["Shape"]); $area->setCoords($areas[$i]["Coords"]); $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2, true, $x_ratio, $y_ratio); } } if ($a_output_new_area) { $area = new ilMapArea(); $area->setShape($a_area_type); $area->setCoords($a_coords); $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2, false, $x_ratio, $y_ratio); } $a_st_item->saveMapWorkImage(); return true; }
/** * draw a new area in work image * * @param string $a_shape shape * @param string $a_coords coordinates string */ function addAreaToMapWorkCopy($a_shape, $a_coords) { $this->buildMapWorkImage(); // determine ratios $size = @getimagesize($this->getMapWorkCopyName()); $x_ratio = 1; if ($size[0] > 0 && $this->getWidth() > 0) { $x_ratio = $this->getWidth() / $size[0]; } $y_ratio = 1; if ($size[1] > 0 && $this->getHeight() > 0) { $y_ratio = $this->getHeight() / $size[1]; } // add new area to work image $area = new ilMapArea(); $area->setShape($a_shape); $area->setCoords($a_coords); $area->draw($this->getMapWorkImage(), $this->color1, $this->color2, false, $x_ratio, $y_ratio); $this->saveMapWorkImage(); }