summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2008-07-18 09:56:33 +0000
committerKore Nordmann <github@kore-nordmann.de>2008-07-18 09:56:33 +0000
commit8e7c90a3ce6ffe407e83d7333f57f225f0c9a9a9 (patch)
tree171a45e3a9a21c3ecb4c80255884641c49dfb37c
parent663755b520265cb1cc4bc3edf30370f54f16c86e (diff)
downloadzetacomponents-graph-8e7c90a3ce6ffe407e83d7333f57f225f0c9a9a9.zip
zetacomponents-graph-8e7c90a3ce6ffe407e83d7333f57f225f0c9a9a9.tar.gz
- Fixed issue #13361: Provided workaround for ext/GD bug:
http://bugs.php.net/45552
-rw-r--r--ChangeLog2
-rw-r--r--src/driver/gd.php22
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawCircleSectorAcuteVerySmallBug13361.pngbin0 -> 339 bytes
-rw-r--r--tests/driver_gd_test.php35
4 files changed, 59 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8061ba1..b9350b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
- Implemented feature #11981: Provide option for exact axis label renderer to
put last value outside of the normal label boundings
- Fixed issue #13253: Division by zero when trying to render stacked bars.
+- Fixed issue #13361: Provided workaround for ext/GD bug:
+ http://bugs.php.net/45552
1.3 - Monday 16 June 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/driver/gd.php b/src/driver/gd.php
index 8f8a7f7..b0472e7 100644
--- a/src/driver/gd.php
+++ b/src/driver/gd.php
@@ -739,6 +739,28 @@ class ezcGraphGdDriver extends ezcGraphDriver
$endAngle = $tmp;
}
+ // 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(
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawCircleSectorAcuteVerySmallBug13361.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawCircleSectorAcuteVerySmallBug13361.png
new file mode 100644
index 0000000..89c1e12
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawCircleSectorAcuteVerySmallBug13361.png
Binary files differ
diff --git a/tests/driver_gd_test.php b/tests/driver_gd_test.php
index e01193a..256cbc5 100644
--- a/tests/driver_gd_test.php
+++ b/tests/driver_gd_test.php
@@ -389,6 +389,41 @@ class ezcGraphGdDriverTest extends ezcTestImageCase
);
}
+ public function testDrawCircleSectorAcuteVerySmallBug13361()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $return = $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 30,
+ 30.1,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+
+ $this->assertEquals(
+ $return,
+ array(),
+ 'Expected empty point array as return value.',
+ 1.
+ );
+ }
+
public function testDrawCircleSectorAcuteNonFilled()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
OpenPOWER on IntegriCloud