public function polygon(awColor $color, awPolygon $polygon) { switch ($polygon->getStyle()) { case awPolygon::SOLID: $thickness = $polygon->getThickness(); $this->startThickness($thickness); $points = $this->getPolygonPoints($polygon); $rgb = $this->getColor($color); imagepolygon($this->resource, $points, $polygon->count(), $rgb); $this->stopThickness($thickness); break; default: if ($polygon->count() > 1) { $prev = $polygon->get(0); $line = new awLine(); $line->setStyle($polygon->getStyle()); $line->setThickness($polygon->getThickness()); for ($i = 1; $i < $polygon->count(); $i++) { $current = $polygon->get($i); $line->setLocation($prev, $current); $this->line($color, $line); $prev = $current; } // Close the polygon $line->setLocation($prev, $polygon->get(0)); $this->line($color, $line); } } }
/** * Draw a polygon * * @param awColor $color Polygon color * @param Polygon A polygon */ public function polygon(awColor $color, awPolygon $polygon) { $points = $polygon->all(); $count = count($points); if ($count > 1) { $side = new awLine(); $side->setStyle($polygon->getStyle()); $side->setThickness($polygon->getThickness()); $prev = $points[0]; for ($i = 1; $i < $count; $i++) { $current = $points[$i]; $side->setLocation($prev, $current); $this->line($color, $side); $prev = $current; } // Close the polygon $side->setLocation($prev, $points[0]); $this->line($color, $side); } }