This has my head wrecked! :-\
I'm drawing a 4-point polygon for a png. I pass an 8-value array, $values, to imagefilledpolygon() to plot the poly. It doesn't work. I create an identical(?) array, $valuestest, and it does work. I do a var_dump for both and they appear identical.
$values = array($X[0], $Y[0], $X[1], $Y[1], $X[3], $Y[3], $X[2], $Y[2] );
$valuestest = array( 10, 50, 31, 34, 86, 73, 64, 89);
// -----0---- ------1----- ------3----- -----2------
if ($debug) {
var_dump($values);echo "(values)<br>";
var_dump($valuestest);echo "(valuestest)<br>";
} else {
header('Content-type: image/png');
$img = imagecreatetruecolor($imgw, $imgh); // set earlier in the script
$blue = imagecolorallocate($img, 0, 0, 255);
// draw a polygon
if (!$test) {
imagefilledpolygon($img, $values, 4, $blue);
} else {
imagefilledpolygon($img, $valuestest, 4, $blue);
}
imagepng($img);
imagedestroy($img);
}
If debug is true then I get a dump as follows:
array( { [0]=> int(10) [1]=> int(50) [2]=> int(31) [3]=> int(34) [4]=> int(86) [5]=> int(73) [6]=> int(64) [7]=> int(89) } (values)
array( { [0]=> int(10) [1]=> int(50) [2]=> int(31) [3]=> int(34) [4]=> int(86) [5]=> int(73) [6]=> int(64) [7]=> int(89) } (valuestest)
In normal mode (both debug and test false) I get a blank (black) image.
If I set test true then I get a blue polygon on the black background (the desired result).
I can't see any difference in the array contents. Why does $values fail while $valuestest works? ??? By creating the $values array with the contents of other arrays have I created a problem?
Many thanks for taking the time to look at this.