Author: Kore Nordmann Date: 2007-02-08 12:11:42 +0100 (Thu, 08 Feb 2007) New Revision: 4640
Log: - Implemented ellipse size reducement in flash driver Modified: trunk/Graph/src/driver/flash.php trunk/Graph/src/interfaces/driver.php trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf trunk/Graph/tests/driver_flash_test.php Modified: trunk/Graph/src/driver/flash.php =================================================================== --- trunk/Graph/src/driver/flash.php 2007-02-08 00:34:43 UTC (rev 4639) +++ trunk/Graph/src/driver/flash.php 2007-02-08 11:11:42 UTC (rev 4640) @@ -593,6 +593,17 @@ $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 Modified: trunk/Graph/src/interfaces/driver.php =================================================================== --- trunk/Graph/src/interfaces/driver.php 2007-02-08 00:34:43 UTC (rev 4639) +++ trunk/Graph/src/interfaces/driver.php 2007-02-08 11:11:42 UTC (rev 4640) @@ -205,8 +205,6 @@ * '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 @@ $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 @@ ); // 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 @@ ); // 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 ) ), ); } Modified: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf =================================================================== (Binary files differ) Modified: trunk/Graph/tests/driver_flash_test.php =================================================================== --- trunk/Graph/tests/driver_flash_test.php 2007-02-08 00:34:43 UTC (rev 4639) +++ trunk/Graph/tests/driver_flash_test.php 2007-02-08 11:11:42 UTC (rev 4640) @@ -210,6 +210,43 @@ ); } + 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'; -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components