php-src/ext/gd/tests/bug64641.phpt
Christoph M. Becker 2de79f0855 Make the $num_points parameter of php_imagepolygon optional
That parameter is mostly useless in practise, and likely has been
directly ported from the underlying `gdImagePolygon()` and friends,
which require that parameter since the number of elements of the point
array would otherwise be unknown.  Typical usages of `imagepolygon()`,
`imageopenpolygon()` and `imagefilledpolygon()` pass `count($points)/2`
or hard-code this value as literal.  Since explicitly specifying this
parameter is annoying and error-prone, we offer the possibility to omit
it, in which case the `$points` array must have an even number of
elements, and the number of points is calculated as `count($points)/2`.
2019-11-15 09:41:10 +01:00

42 lines
800 B
PHP

--TEST--
Bug #64641 (imagefilledpolygon doesn't draw horizontal line)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.2', '<')) {
die("skip test requires GD 2.2.2 or higher");
}
?>
--FILE--
<?php
require_once __DIR__ . '/similarity.inc';
$im = imagecreatetruecolor(640, 480);
$points = array(
100, 100,
100, 200,
100, 300
);
imagefilledpolygon($im, $points, 0xFFFF00);
$points = array(
300, 200,
400, 200,
500, 200
);
imagefilledpolygon($im, $points, 0xFFFF00);
$ex = imagecreatefrompng(__DIR__ . '/bug64641.png');
if (($diss = calc_image_dissimilarity($ex, $im)) < 1e-5) {
echo "IDENTICAL";
} else {
echo "DISSIMILARITY: $diss";
}
imagedestroy($ex);
imagedestroy($im);
?>
--EXPECT--
IDENTICAL