/** * Draws a sector of cirlce * * @param ezcGraphCoordinate $center Center of circle * @param mixed $width Width * @param mixed $height Height * @param mixed $startAngle Start angle of circle sector * @param mixed $endAngle End angle of circle sector * @param ezcGraphColor $color Color * @param mixed $filled Filled * @return void */ public function drawCircleSector(ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true) { $image = $this->getImage(); $drawColor = $this->allocate($color); // Normalize angles if ($startAngle > $endAngle) { $tmp = $startAngle; $startAngle = $endAngle; $endAngle = $tmp; } if ($endAngle - $startAngle > 359.99999) { return $this->drawCircle($center, $width, $height, $color, $filled); } // Because of bug #45552 in PHPs ext/GD we check for a minimal distance // on the outer border of the circle sector, and skip the drawing if // the distance is lower then 1. // // See also: http://bugs.php.net/45552 $startPoint = new ezcGraphVector($center->x + cos(deg2rad($startAngle)) * $width / 2, $center->y + sin(deg2rad($startAngle)) * $height / 2); if ($startPoint->sub(new ezcGraphVector($center->x + cos(deg2rad($endAngle)) * $width / 2, $center->y + sin(deg2rad($endAngle)) * $height / 2))->length() < 1) { // Skip this circle sector return array(); } if ($filled) { imagefilledarc($image, $this->supersample($center->x), $this->supersample($center->y), $this->supersample($width), $this->supersample($height), $startAngle, $endAngle, $drawColor, IMG_ARC_PIE); } else { imagefilledarc($image, $this->supersample($center->x), $this->supersample($center->y), $this->supersample($width), $this->supersample($height), $startAngle, $endAngle, $drawColor, IMG_ARC_PIE | IMG_ARC_NOFILL | IMG_ARC_EDGED); } // Create polygon array to return $polygonArray = array($center); for ($angle = $startAngle; $angle < $endAngle; $angle += $this->options->imageMapResolution) { $polygonArray[] = new ezcGraphCoordinate($center->x + cos(deg2rad($angle)) * $width / 2, $center->y + sin(deg2rad($angle)) * $height / 2); } $polygonArray[] = new ezcGraphCoordinate($center->x + cos(deg2rad($endAngle)) * $width / 2, $center->y + sin(deg2rad($endAngle)) * $height / 2); return $polygonArray; }
public function testVectorSubVector() { $vector = new ezcGraphVector(1, 2); $result = $vector->sub(new ezcGraphVector(3, 2)); $this->assertEquals($vector, new ezcGraphVector(-2, 0)); $this->assertEquals($result, $vector, 'Result should be the vector itself'); }