summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-02-08 11:11:42 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-02-08 11:11:42 +0000
commitb8f51740e26dee3f8fdd937dcaac7f0d437fe785 (patch)
tree9026ecfae7b979a1ee6d1554521d2e33e783c108
parent47c7a25d15c25ae051af381046b8257e9b2a9a46 (diff)
downloadzetacomponents-graph-b8f51740e26dee3f8fdd937dcaac7f0d437fe785.zip
zetacomponents-graph-b8f51740e26dee3f8fdd937dcaac7f0d437fe785.tar.gz
- Implemented ellipse size reducement in flash driver
-rw-r--r--src/driver/flash.php11
-rw-r--r--src/interfaces/driver.php22
-rw-r--r--tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swfbin128 -> 122 bytes
-rw-r--r--tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swfbin49051 -> 49047 bytes
-rw-r--r--tests/driver_flash_test.php37
5 files changed, 62 insertions, 8 deletions
diff --git a/src/driver/flash.php b/src/driver/flash.php
index 4c438fa..3ebde93 100644
--- a/src/driver/flash.php
+++ b/src/driver/flash.php
@@ -593,6 +593,17 @@ class ezcGraphFlashDriver extends ezcGraphDriver
$shape = new SWFShape();
$this->setShapeColor( $shape, $color, 1, $filled );
+ if ( !$filled )
+ {
+ $reduced = $this->reduceEllipseSize( $center, $width, $height, $startAngle, $endAngle, .5 );
+
+ $startAngle = $reduced['startAngle'];
+ $endAngle = $reduced['endAngle'];
+
+ $width -= 1;
+ $height -= 1;
+ }
+
$shape->movePenTo( $this->modifyCoordinate( $center->x ), $this->modifyCoordinate( $center->y ) );
// @TODO: User SWFShape::curveTo
diff --git a/src/interfaces/driver.php b/src/interfaces/driver.php
index 5c3b755..e8d5adb 100644
--- a/src/interfaces/driver.php
+++ b/src/interfaces/driver.php
@@ -205,8 +205,6 @@ abstract class ezcGraphDriver
* 'center' => (ezcGraphCoordinate) New center point,
* 'start' => (ezcGraphCoordinate) New outer start point,
* 'end' => (ezcGraphCoordinate) New outer end point,
- * 'startAngle' => (float) Angle from old center point to new start point,
- * 'endAngle' => (float) Angle from old center point to new end point,
* )
*
* @param ezcGraphCoordinate $center
@@ -232,19 +230,21 @@ abstract class ezcGraphDriver
$endAngle = deg2rad( $endAngle );
// Calculate normalized vectors for the lines spanning the ellipse
- $startVector = ezcGraphVector::fromCoordinate( $oldStartPoint )->unify();
- $endVector = ezcGraphVector::fromCoordinate( $oldEndPoint )->unify();
+ $unifiedStartVector = ezcGraphVector::fromCoordinate( $oldStartPoint )->unify();
+ $unifiedEndVector = ezcGraphVector::fromCoordinate( $oldEndPoint )->unify();
+ $startVector = ezcGraphVector::fromCoordinate( $oldStartPoint );
+ $endVector = ezcGraphVector::fromCoordinate( $oldEndPoint );
$oldStartPoint->add( $center );
$oldEndPoint->add( $center );
// Use orthogonal vectors of normalized ellipse spanning vectors to
- $v = clone $startVector;
+ $v = clone $unifiedStartVector;
$v->rotateClockwise()->scalar( $size );
// calculate new center point
// center + v + size / tan( angle / 2 ) * startVector
- $centerMovement = clone $startVector;
+ $centerMovement = clone $unifiedStartVector;
$newCenter = $v->add( $centerMovement->scalar( $size / tan( ( $endAngle - $startAngle ) / 2 ) ) )->add( $center );
// Use start spanning vector and its orthogonal vector to calculate
@@ -266,10 +266,12 @@ abstract class ezcGraphDriver
);
// Reverse spanning vector
- $innerVector = clone $startVector;
+ $innerVector = clone $unifiedStartVector;
$innerVector->scalar( $size )->scalar( -1 );
$newStartPoint->add( $innerVector)->add( $ellipseTangentVector->scalar( $size ) );
+ $newStartVector = clone $startVector;
+ $newStartVector->add( $ellipseTangentVector );
// Use end spanning vector and its orthogonal vector to calculate
// new end point
@@ -290,15 +292,19 @@ abstract class ezcGraphDriver
);
// Reverse spanning vector
- $innerVector = clone $endVector;
+ $innerVector = clone $unifiedEndVector;
$innerVector->scalar( $size )->scalar( -1 );
$newEndPoint->add( $innerVector )->add( $ellipseTangentVector->scalar( $size )->scalar( -1 ) );
+ $newEndVector = clone $endVector;
+ $newEndVector->add( $ellipseTangentVector );
return array(
'center' => $newCenter,
'start' => $newStartPoint,
'end' => $newEndPoint,
+ 'startAngle' => rad2deg( $startAngle + $startVector->angle( $newStartVector ) ),
+ 'endAngle' => rad2deg( $endAngle - $endVector->angle( $newEndVector ) ),
);
}
diff --git a/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf b/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf
index e981e92..b4dabab 100644
--- a/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf
+++ b/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf
Binary files differ
diff --git a/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf b/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf
index ee4e958..fd1d4d0 100644
--- a/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf
+++ b/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf
Binary files differ
diff --git a/tests/driver_flash_test.php b/tests/driver_flash_test.php
index 036e04e..802cf3a 100644
--- a/tests/driver_flash_test.php
+++ b/tests/driver_flash_test.php
@@ -210,6 +210,43 @@ class ezcGraphFlashDriverTest extends ezcGraphTestCase
);
}
+ public function testDrawCircleSectorBorderReducement()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.swf';
+
+ $angles = array( 10, 25, 45, 90, 125, 180, 235, 340 );
+
+ $position = 0;
+ $radius = 80;
+ foreach ( $angles as $angle )
+ {
+ while ( $position < 360 )
+ {
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ $radius,
+ $radius / 2,
+ $position,
+ $position += $angle,
+ ezcGraphColor::fromHex( '#3465A480' ),
+ false
+ );
+
+ $position += 5;
+ }
+
+ $position = 0;
+ $radius += 15;
+ }
+
+ $this->driver->render( $filename );
+
+ $this->swfCompare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf'
+ );
+ }
+
public function testDrawMultipleBigCircleSectors()
{
$filename = $this->tempDir . __FUNCTION__ . '.swf';
OpenPOWER on IntegriCloud