Test and document filling behavior of self-intersecting polygons

master
Christoph M. Becker 2016-10-01 19:54:10 +02:00
parent d79ea8f1cb
commit 30453e94b2
6 changed files with 43 additions and 4 deletions

View File

@ -3467,8 +3467,8 @@ BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
*
* Parameters:
* im - The image.
* p - The vertices.
* n - The number of vertices as array of <gdPoint>s.
* p - The vertices as array of <gdPoint>s.
* n - The number of vertices.
* c - The color
*
* See also:
@ -3506,6 +3506,10 @@ BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
*
* Draws a filled polygon
*
* The polygon is filled using the even-odd fillrule what can leave unfilled
* regions inside of self-intersecting polygons. This behavior might change in
* a future version.
*
* Parameters:
* im - The image.
* p - The vertices as array of <gdPoint>s.

View File

@ -4,3 +4,4 @@
/gdimagefilledpolygon2
/gdimagefilledpolygon3
/php_bug_64641
/self_intersecting

View File

@ -5,6 +5,7 @@ LIST(APPEND TESTS_FILES
gdimagefilledpolygon3
bug00100
php_bug_64641
self_intersecting
)
ADD_GD_TESTS()

View File

@ -5,7 +5,8 @@ libgd_test_programs += \
gdimagefilledpolygon/gdimagefilledpolygon1 \
gdimagefilledpolygon/gdimagefilledpolygon2 \
gdimagefilledpolygon/gdimagefilledpolygon3 \
gdimagefilledpolygon/php_bug_64641
gdimagefilledpolygon/php_bug_64641 \
gdimagefilledpolygon/self_intersecting
endif
EXTRA_DIST += \
@ -15,4 +16,5 @@ EXTRA_DIST += \
gdimagefilledpolygon/gdimagefilledpolygon1.png \
gdimagefilledpolygon/gdimagefilledpolygon2.png \
gdimagefilledpolygon/gdimagefilledpolygon3.png \
gdimagefilledpolygon/php_bug_64641.png
gdimagefilledpolygon/php_bug_64641.png \
gdimagefilledpolygon/self_intersecting_exp.png

View File

@ -0,0 +1,31 @@
/**
* We're testing the filling behavior of self-intersecting polygons, which is
* *currently* using the even-odd fillrule.
*/
#include "gd.h"
#include "gdtest.h"
int main()
{
gdImagePtr im;
int black;
gdPoint points[] = {{50, 5}, {24, 86}, {93, 36}, {7, 36}, {76, 86}};
char *path;
im = gdImageCreate(100, 100);
gdImageColorAllocate(im, 255, 255, 255);
black = gdImageColorAllocate(im, 0, 0, 0);
gdImageFilledPolygon(im, points, 5, black);
path = gdTestFilePath2("gdimagefilledpolygon", "self_intersecting_exp.png");
gdAssertImageEqualsToFile(path, im);
gdFree(path);
gdImageDestroy(im);
return gdNumFailures();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B