Example #1
0
 public function __construct($points)
 {
     parent::__construct();
     $polygon = new Image_3D_Polygon();
     foreach ($points as $point) {
         $polygon->addPoint($point);
     }
     $this->_addPolygon($polygon);
 }
Example #2
0
 public function drawPolygon(Image_3D_Polygon $polygon)
 {
     // Build pointarray
     $pointArray = array();
     $points = $polygon->getPoints();
     foreach ($points as $point) {
         $screenCoordinates = $point->getScreenCoordinates();
         $this->_image->addVertex(array('x' => $screenCoordinates[0], 'y' => $screenCoordinates[1]));
     }
     $this->_image->setFillColor($this->_getColor($polygon->getColor()));
     $this->_image->setLineColor(false);
     $this->_image->polygon(array('connect' => true));
 }
Example #3
0
 public function drawPolygon(Image_3D_Polygon $polygon)
 {
     // Get points
     $points = $polygon->getPoints();
     $coords = array();
     $coords = '';
     foreach ($points as $point) {
         $pointCoords = $point->getScreenCoordinates();
         $coords .= (int) $pointCoords[0] . ',' . (int) $pointCoords[1] . ' ';
     }
     $command = '-fill ' . escapeshellarg($this->_getColor($polygon->getColor()));
     $command .= ' -draw ' . escapeshellarg('polygon ' . trim($coords));
     $this->_commandQueue[] = $command;
 }
Example #4
0
 public function drawPolygon(Image_3D_Polygon $polygon)
 {
     // Get points
     $points = $polygon->getPoints();
     $coords = array();
     foreach ($points as $point) {
         $coords = array_merge($coords, $point->getScreenCoordinates());
     }
     $coordCount = (int) (count($coords) / 2);
     if (true) {
         imageFilledPolygon($this->_image, $coords, $coordCount, $this->_getColor($polygon->getColor()));
     } else {
         imagePolygon($this->_image, $coords, $coordCount, $this->_getColor($polygon->getColor()));
     }
 }
Example #5
0
 public function drawPolygon(Image_3D_Polygon $polygon)
 {
     $points = $this->_getPolygonOutlines($polygon->getPoints());
     foreach ($points as $x => $row) {
         if (count($row) < 2) {
             continue;
         }
         $start = min(array_keys($row));
         $end = max(array_keys($row));
         // Starting point
         $this->_heigth[$x][$start] = $this->_getColor($polygon->getColor());
         // the way between
         for ($y = $start + 1; $y < $end; ++$y) {
             $this->_heigth[$x][$y] = $this->_getColor($polygon->getColor());
         }
         // Ending point
         $this->_points[$x][$end] = $this->_getColor($polygon->getColor());
     }
 }
Example #6
0
 public function drawGradientPolygon(Image_3D_Polygon $polygon)
 {
     $points = $polygon->getPoints();
     $list = '';
     $pointarray = array();
     foreach ($points as $nr => $point) {
         $pointarray[$nr] = $point->getScreenCoordinates();
         $list .= sprintf('%.2f,%.2f ', $pointarray[$nr][0], $pointarray[$nr][1]);
     }
     // Groessen
     $xOffset = min($pointarray[0][0], $pointarray[1][0], $pointarray[2][0]);
     $yOffset = min($pointarray[0][1], $pointarray[1][1], $pointarray[2][1]);
     $xSize = max(abs($pointarray[0][0] - $pointarray[1][0]), abs($pointarray[0][0] - $pointarray[2][0]), abs($pointarray[1][0] - $pointarray[2][0]));
     $ySize = max(abs($pointarray[0][1] - $pointarray[1][1]), abs($pointarray[0][1] - $pointarray[2][1]), abs($pointarray[1][1] - $pointarray[2][1]));
     // Base Polygon
     $lg = $this->_addGradient(sprintf("\t\t<linearGradient id=\"[id]\" x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\">\n%s\t\t</linearGradient>\n", ($pointarray[0][0] - $xOffset) / $xSize, ($pointarray[0][1] - $yOffset) / $ySize, ($pointarray[1][0] - $xOffset) / $xSize, ($pointarray[1][1] - $yOffset) / $ySize, $this->_getStop($points[0]->getColor()) . $this->_getStop($points[1]->getColor(), 1)));
     $this->_addPolygon(sprintf("\t<polygon id=\"[id]\" points=\"%s\" style=\"fill: url(#%s); stroke: none; fill-opacity: 1;\" />\n", $list, $lg));
     // Overlay Polygon
     $lg = $this->_addGradient(sprintf("\t\t<linearGradient id=\"[id]\" x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\">\n%s\t\t</linearGradient>\n", ($pointarray[2][0] - $xOffset) / $xSize, ($pointarray[2][1] - $yOffset) / $ySize, (($pointarray[0][0] + $pointarray[1][0]) / 2 - $xOffset) / $xSize, (($pointarray[0][1] + $pointarray[1][1]) / 2 - $yOffset) / $ySize, $this->_getStop($points[2]->getColor()) . $this->_getStop($points[2]->getColor(), 1, 1)));
     $this->_addPolygon(sprintf("\t<polygon id=\"[id]\" points=\"%s\" style=\"fill: url(#%s); stroke: none; fill-opacity: 1;\" />\n", $list, $lg));
 }
Example #7
0
 public function drawPolygon(Image_3D_Polygon $polygon)
 {
     $points = $this->_getPolygonOutlines($polygon->getPoints());
     foreach ($points['coverage'] as $x => $row) {
         if (count($row) < 2) {
             continue;
         }
         $start = min(array_keys($row));
         $end = max(array_keys($row));
         $zStart = $points['height'][$x][$start];
         $zEnd = $points['height'][$x][$end];
         $zStep = ($zEnd - $zStart) / ($end - $start);
         // Starting point
         $this->_heigth[$x][$start][(int) ($zStart * 100)] = $this->_getColor($polygon->getColor(), $points['coverage'][$x][$start]);
         // the way between
         for ($y = $start + 1; $y < $end; $y++) {
             $this->_heigth[$x][$y][(int) (($zStart + $zStep * ($y - $start)) * 100)] = $this->_getColor($polygon->getColor());
         }
         // Ending point
         $this->_points[$x][$end][(int) ($zEnd * 100)] = $this->_getColor($polygon->getColor(), $points['coverage'][$x][$end]);
     }
 }
Example #8
0
 public function drawPolygon(Image_3D_Polygon $polygon)
 {
     $list = '';
     $points = $polygon->getPoints();
     $svg = "\t\t\t<polygon id=\"[id]\" ";
     //Image_3D_P
     // number of points
     $svg .= 'nop="' . count($points) . '" ';
     // coordinates on start
     foreach ($points as $nr => $point) {
         $svg .= 'x' . $nr . '="' . round($point->getX()) . '" ';
         $svg .= 'y' . $nr . '="' . round($point->getY()) . '" ';
         $svg .= 'z' . $nr . '="' . round($point->getZ()) . '" ';
     }
     $svg .= 'style="' . $this->_getStyle($polygon->getColor()) . "\" />\n";
     $this->_addPolygon($svg);
 }
Example #9
0
 /**
  * Draw a specified polygon utilizing gradients between his points for
  * color representation (Gauroud-Shading)
  * 
  * @param Image_3D_Polygon $polygon Polygon to draw
  * 
  * @return void
  */
 public function drawGradientPolygon(Image_3D_Polygon $polygon)
 {
     $pointarray = array();
     $colorarray = array();
     $points = $polygon->getPoints();
     foreach ($points as $key => $point) {
         $pointarray[$key] = array('x' => $point->getX(), 'y' => $point->getY(), 'z' => $point->getZ());
         $colorarray[$key] = $this->_getRgba($point->getColor());
     }
     $this->_addPolygon($pointarray, $colorarray);
 }