1
I가 GD를 사용하여 이미지에 녹색 사각형을 그립니다 다음 코드를PHP GD는 foreach 루프에서 그리기
$img = imagecreatefrompng("images/dota.png");
$radiantcolor = imagecolorallocate($img, 7, 251, 15);
$direcolor = imagecolorallocate($img, 250, 2, 0);
$x = array(
0 => 38,
1 => 45,
2 => 25,
3 => 29,
4 => 34,
5 => 62,
6 => 83,
7 => 116,
8 => 76,
9 => 135,
10 => 232,
);
$y = array(
0 => 234,
1 => 240,
2 => 205,
3 => 161,
4 => 116,
5 => 219,
6 => 198,
7 => 171,
8 => 256,
9 => 260,
10 => 257,
);
foreach ($towerstatus_radiant as $key => $tower){
if ($tower == 1){
$x = $x[$key];
$y = $y[$key];
imagefilledrectangle($img, $x, $y, $x+8, $y+8, $radiantcolor);
}
}
header('Content-Type: image/png');
imagepng($img);
그것은 최초의 사각형 잘 작동하지만 그 후, 사각형 그냥 것 같다 다음과 같이 왼쪽 상단 모서리에 배치 :
왜 이런 일이있을 수 있을까?
'$ towerstatus_radiant'가 코드에 정의되어 있지 않으므로 아무에게도 말할 수 없어 추측 할 수 있어야합니다. 디버깅 할 때 추측을 방지해야합니다. – hakre