說明
bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
imagefilledrectangle() 在 image 圖像中畫一個用 color 顏色填充了的矩形,
其左上角坐標為 x1,y1,右下角坐標為 x2,y2。0, 0 是圖像的最左上角。
<?php
$image = imagecreate(400,300);
$gold = imagecolorallocate($image, 255, 240, 00);
$white = imagecolorallocate($image, 255, 255, 255);
$colour = $white;
for ($i = 400, $j = 300; $i > 0; $i -= 4, $j -= 3) {
if ($colour == $white) {
$colour = $gold;
} else {
$colour = $white;
}
imagefilledrectangle($image, 400 - $i, 300 - $j, $i, $j, $colour);
}
imagepng($image);
imagedestroy($image);
?>
全站熱搜