PHP/Graphics Image/Rectangle

Материал из Web эксперт
Перейти к: навигация, поиск

Drawing a Filled Rectangle with imagefilledrectangle()

<?php
 header("Content-type: image/gif");
 $image = imagecreate( 200, 200 );
 $red = imagecolorallocate($image, 255,0,0);
 $blue = imagecolorallocate($image, 0,0,255 );
 imagefilledrectangle( $image, 19, 19, 179, 179, $blue );
 imagegif( $image );
?>



Fill Rectangle

<html>
<body>
<?php
    $pic=ImageCreate(600,600);
    $col1=ImageColorAllocate($pic,200,200,200);
    $col2=ImageColorAllocate($pic,0,0,255);
    ImageFilledRectangle($pic,1,1,100,100,$col2);
    ImagePNG($pic,"pic.png");
    ImageDestroy($pic);
?>
<img src="pic.png" border=0>
</body>
</html>