Author: Kore Nordmann Date: 2007-02-01 13:20:16 +0100 (Thu, 01 Feb 2007) New Revision: 4609
Log: - Correctly fixed polygon size reducement Modified: trunk/Graph/src/driver/flash.php trunk/Graph/src/driver/svg.php trunk/Graph/src/interfaces/driver.php trunk/Graph/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomCenter.svg trunk/Graph/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithHorizontalTextureBackground.svg trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonThreePointsNotFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChart.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledAxis.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledGrid.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithAxisIntersection.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithoutDataBorder.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChart.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartBigMaxFontSize.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartSmallMaxFontSize.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderBarChart.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderBarChartSymbols.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderFullShadow.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieChartBlue.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieChartEz.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegment.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentPolygonOrder.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomHeight.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomRotation.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithGleamAndShadow.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithIncreasedMoveOut.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithModifiedSymbolColor.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithTitle.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutDataBorder.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutSymbols.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartToOutput.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithAxisLabels.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithAxisLabelsReversedAxis.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithDifferentAxisSpace.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithHighlightedData.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderNegativeBarChartSymbols.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithLotsOfLabels.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithOffset.svg trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderPimpedBarChart.svg trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testChangeDefaultRenderSettings.svg trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplate.svg trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplateCustomGroup.svg trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartWithCustomPrefix.svg trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsNotFilled.svg trunk/Graph/tests/driver_svg_test.php Modified: trunk/Graph/src/driver/flash.php =================================================================== --- trunk/Graph/src/driver/flash.php 2007-02-01 12:19:17 UTC (rev 4608) +++ trunk/Graph/src/driver/flash.php 2007-02-01 12:20:16 UTC (rev 4609) @@ -194,7 +194,7 @@ { // The middle of the border is on the outline of a polygon in ming, // fix that: - // $points = $this->reducePolygonSize( $points, $thickness / 2 ); + $points = $this->reducePolygonSize( $points, $thickness / 2 ); } $shape = new SWFShape(); Modified: trunk/Graph/src/driver/svg.php =================================================================== --- trunk/Graph/src/driver/svg.php 2007-02-01 12:19:17 UTC (rev 4608) +++ trunk/Graph/src/driver/svg.php 2007-02-01 12:20:16 UTC (rev 4609) @@ -332,7 +332,7 @@ { // The middle of the border is on the outline of a polygon in SVG, // fix that: - // $points = $this->reducePolygonSize( $points, $thickness / 2 ); + $points = $this->reducePolygonSize( $points, $thickness / 2 ); } $lastPoint = end( $points ); Modified: trunk/Graph/src/interfaces/driver.php =================================================================== --- trunk/Graph/src/interfaces/driver.php 2007-02-01 12:19:17 UTC (rev 4608) +++ trunk/Graph/src/interfaces/driver.php 2007-02-01 12:20:16 UTC (rev 4609) @@ -109,8 +109,32 @@ $vectors[$i] = ezcGraphVector::fromCoordinate( $points[$nextPoint] ) ->sub( $points[$i] ) ->unify(); + + if ( ( $vectors[$i]->x == $vectors[$i]->y ) && ( $vectors[$i]->x == 0 ) ) + { + // Remove point from list if it the same as the next point + $pointCount--; + if ( $i === 0 ) + { + $points = array_slice( $points, $i + 1 ); + } + else + { + $points = array_merge( + array_slice( $points, 0, $i ), + array_slice( $points, $i + 1 ) + ); + } + $i--; + } } + // No reducements for lines + if ( $pointCount <= 2 ) + { + return $points; + } + // Move points to center $newPoints = array(); for ( $i = 0; $i < $pointCount; ++$i ) @@ -137,27 +161,37 @@ $v = clone $vectors[$next]; if ( $sign > 0 ) { - $v->rotateClockwise()->scalar( $size ); + $v->rotateCounterClockwise()->scalar( $size ); } else { - $v->rotateCounterClockwise()->scalar( $size ); + $v->rotateClockwise()->scalar( $size ); } + // get last vector not pointing in reverse direction + $lastVector = clone $vectors[$last]; + $lastVector->scalar( -1 ); + // Calculate new point: Move point to the center site of the // polygon using the normalized orthogonal vectors next to the // point and the size as distance to move. // point + v + size / tan( angle / 2 ) * startVector $newPoint = clone $vectors[$next]; + $angle = $lastVector->angle( $vectors[$next] ) / 2; + + if ( $angle == 0 ) + { + var_dump( $points, $vectors ); + debug_print_backtrace(); + die( 'Fin' ); + } $newPoints[$next] = $v ->add( $newPoint ->scalar( $size / tan( - $vectors[$last] - ->mul( $vectors[$next] ) / - 2 + $lastVector->angle( $vectors[$next] ) / 2 ) ) ) @@ -228,7 +262,6 @@ $orthogonalVector = clone $startVector; $orthogonalVector->scalar( $size )->rotateClockwise(); - var_dump( '===', $newStartPoint, $innerVector, $orthogonalVector ); $newStartPoint->add( $innerVector)->add( $orthogonalVector ); // Use end spanning vector and its orthogonal vector to calculate @@ -243,8 +276,6 @@ $newEndPoint->add( $innerVector )->add( $orthogonalVector ); - var_dump( $newCenter, $newStartPoint, $newEndPoint ); - return array( 'center' => $newCenter, 'start' => $newStartPoint, Modified: trunk/Graph/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomCenter.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithHorizontalTextureBackground.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonThreePointsNotFilled.swf =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChart.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledAxis.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledGrid.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithAxisIntersection.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithoutDataBorder.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChart.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartBigMaxFontSize.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChartSmallMaxFontSize.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderBarChart.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderBarChartSymbols.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderFullShadow.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieChartBlue.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieChartEz.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegment.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentPolygonOrder.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomHeight.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomRotation.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithGleamAndShadow.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithIncreasedMoveOut.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithModifiedSymbolColor.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithTitle.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutDataBorder.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutSymbols.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartToOutput.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithAxisLabels.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithAxisLabelsReversedAxis.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithDifferentAxisSpace.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderLineChartWithHighlightedData.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderNegativeBarChartSymbols.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithLotsOfLabels.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithOffset.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphRenderer3dTest_testRenderPimpedBarChart.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testChangeDefaultRenderSettings.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplate.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplateCustomGroup.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartWithCustomPrefix.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsNotFilled.svg =================================================================== (Binary files differ) Modified: trunk/Graph/tests/driver_svg_test.php =================================================================== --- trunk/Graph/tests/driver_svg_test.php 2007-02-01 12:19:17 UTC (rev 4608) +++ trunk/Graph/tests/driver_svg_test.php 2007-02-01 12:20:16 UTC (rev 4609) @@ -139,7 +139,7 @@ new ezcGraphCoordinate( 122, 34 ), new ezcGraphCoordinate( 12, 71 ), ), - ezcGraphColor::fromHex( '#3465A4' ), + ezcGraphColor::fromHex( '#3465A480' ), false ); @@ -151,6 +151,28 @@ ); } + public function testDrawPolygonThreePointsNotFilledReverse() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 12, 71 ), + new ezcGraphCoordinate( 122, 34 ), + new ezcGraphCoordinate( 45, 12 ), + ), + ezcGraphColor::fromHex( '#3465A480' ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + public function testDrawPolygonFivePoints() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; @@ -202,6 +224,43 @@ ); } + public function testDrawCircleSectorBorderReducement() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $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->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + public function testDrawCircleSectorAcuteNonFilled() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; @@ -212,7 +271,7 @@ 40, 12.5, 45, - ezcGraphColor::fromHex( '#3465A4' ), + ezcGraphColor::fromHex( '#3465A480' ), false ); @@ -224,6 +283,28 @@ ); } + public function testDrawCircleSectorObtuseNonFilled() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + 25, + 273, + ezcGraphColor::fromHex( '#3465A480' ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + public function testDrawCircleSectorAcuteReverse() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components