summaryrefslogtreecommitdiffstats
path: root/src/driver
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-05-30 10:24:32 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-05-30 10:24:32 +0000
commite474041293c79a80ca818338a5dde07e6d1fc898 (patch)
tree7743c13ce58d7cecf9b7e3c153d2de1be7c8ff2e /src/driver
parenta2be390c78a5b98655b08fc5c3da6c688011922d (diff)
downloadzetacomponents-graph-e474041293c79a80ca818338a5dde07e6d1fc898.zip
zetacomponents-graph-e474041293c79a80ca818338a5dde07e6d1fc898.tar.gz
- Implemented circular arcs for gd driver
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/gd.php123
-rw-r--r--src/driver/svg.php21
2 files changed, 129 insertions, 15 deletions
diff --git a/src/driver/gd.php b/src/driver/gd.php
index 5172334..59a7a4e 100644
--- a/src/driver/gd.php
+++ b/src/driver/gd.php
@@ -170,23 +170,130 @@ class ezcGraphGdDriver extends ezcGraphDriver
*/
public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color )
{
-
+ $image = $this->getImage();
+ $drawColor = $this->allocate( $color );
+
+ // Normalize angles
+ if ( $startAngle > $endAngle )
+ {
+ $tmp = $startAngle;
+ $startAngle = $endAngle;
+ $endAngle = $tmp;
+ }
+
+ imagefilledarc( $image, $center->x, $center->y, $width, $height, $startAngle, $endAngle, $drawColor, IMG_ARC_PIE );
}
/**
* Draws a circular arc
*
- * @param ezcGraphCoordinate $center
- * @param mixed $width
- * @param mixed $height
- * @param mixed $startAngle
- * @param mixed $endAngle
- * @param ezcGraphColor $color
+ * @param ezcGraphCoordinate $center Center of ellipse
+ * @param integer $width Width of ellipse
+ * @param integer $height Height of ellipse
+ * @param integer $size Height of border
+ * @param float $startAngle Starting angle of circle sector
+ * @param float $endAngle Ending angle of circle sector
+ * @param ezcGraphColor $color Color of Border
* @return void
*/
- public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color )
+ public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color )
{
+ $image = $this->getImage();
+ $drawColor = $this->allocate( $color );
+
+ // Normalize angles
+ if ( $startAngle > $endAngle )
+ {
+ $tmp = $startAngle;
+ $startAngle = $endAngle;
+ $endAngle = $tmp;
+ }
+ $startIteration = ceil( $startAngle / $this->options->detail ) * $this->options->detail;
+ $endIteration = floor( $endAngle / $this->options->detail ) * $this->options->detail;
+
+
+ if ( $startAngle < $startIteration )
+ {
+ // Draw initial step
+ $this->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $startAngle ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $startAngle ) ) * $height ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $startAngle ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $startAngle ) ) * $height + $size ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $startIteration ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $startIteration ) ) * $height + $size ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $startIteration ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $startIteration ) ) * $height ) / 2 )
+ ),
+ ),
+ $color->darken( $this->options->shadeCircularArc * abs ( cos ( deg2rad( $startIteration ) ) ) ),
+ true
+ );
+ }
+
+ // Draw all steps
+ for ( ; $startIteration < $endIteration; $startIteration += $this->options->detail )
+ {
+ $end = $startIteration + $this->options->detail;
+ $this->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $startIteration ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $startIteration ) ) * $height ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $startIteration ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $startIteration ) ) * $height + $size ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $end ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $end ) ) * $height + $size ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $end ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $end ) ) * $height ) / 2 )
+ ),
+ ),
+ $color->darken( $this->options->shadeCircularArc * abs ( cos ( deg2rad( $startIteration ) ) ) ),
+ true
+ );
+ }
+
+ if ( $endIteration < $endAngle )
+ {
+ // Draw closing step
+ $this->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $endIteration ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $endIteration ) ) * $height ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $endIteration ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $endIteration ) ) * $height + $size ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $endAngle ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $endAngle ) ) * $height + $size ) / 2 )
+ ),
+ new ezcGraphCoordinate(
+ $center->x + ( ( cos( deg2rad( $endAngle ) ) * $width ) / 2 ),
+ $center->y + ( ( sin( deg2rad( $endAngle ) ) * $height ) / 2 )
+ ),
+ ),
+ $color->darken( $this->options->shadeCircularArc * abs ( cos ( deg2rad( $endIteration ) ) ) ),
+ true
+ );
+ }
}
/**
diff --git a/src/driver/svg.php b/src/driver/svg.php
index 54e9689..55c0ad5 100644
--- a/src/driver/svg.php
+++ b/src/driver/svg.php
@@ -15,6 +15,12 @@
class ezcGraphSVGDriver extends ezcGraphDriver
{
+
+ public function __construct( array $options = array() )
+ {
+
+ }
+
/**
* Draws a single polygon
*
@@ -75,15 +81,16 @@ class ezcGraphSVGDriver extends ezcGraphDriver
/**
* Draws a circular arc
*
- * @param ezcGraphCoordinate $center
- * @param mixed $width
- * @param mixed $height
- * @param mixed $startAngle
- * @param mixed $endAngle
- * @param ezcGraphColor $color
+ * @param ezcGraphCoordinate $center Center of ellipse
+ * @param integer $width Width of ellipse
+ * @param integer $height Height of ellipse
+ * @param integer $size Height of border
+ * @param float $startAngle Starting angle of circle sector
+ * @param float $endAngle Ending angle of circle sector
+ * @param ezcGraphColor $color Color of Border
* @return void
*/
- public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color )
+ public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color )
{
}
OpenPOWER on IntegriCloud