imagerectangle()创建一个从指定坐标开始的矩形。
句法
PHP imagerectangle()函数具有以下语法。
bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
参数
PHP imagerectangle()函数具有以下参数。
- image - 由图像创建函数(如imagecreatetruecolor())返回的图像资源。
- x1 - 左上角x坐标。
- y1 - 左上y坐标0,0是图像的左上角。
- x2 - 右下角x坐标。
- y2 - 右下y坐标。
- color - 使用imagecolorallocate()创建的颜色标识符。
返回值
成功时返回TRUE,失败时返回FALSE。
实例
<?php
/*
http://www.manongjc.com/article/1757.html
作者:码农教程
*/
// Create a 200 x 200 image
$canvas = imagecreatetruecolor(200, 200);
// Allocate colors
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 132, 135, 28);
// Draw three rectangles each with its own color
imagerectangle($canvas, 50, 50, 150, 150, $pink);
imagerectangle($canvas, 45, 60, 120, 100, $white);
imagerectangle($canvas, 100, 120, 75, 160, $green);
// Output and free from memory
header(\'Content-Type: image/jpeg\');
imagejpeg($canvas);
imagedestroy($canvas);
?> 继续阅读与本文标签相同的文章
上一篇 :
php imagepolygon()函数
-
idea git 下载项目
2026-05-15栏目: 教程
-
修理厂对优拆赞不绝口,优质服务的背后是怎样的一群人
2026-05-15栏目: 教程
-
制造厂用什么管理软件?
2026-05-15栏目: 教程
-
大数据时代在网络信息检索中遇到的主要问题是什么?
2026-05-15栏目: 教程
-
人工智能将如何改变世界
2026-05-15栏目: 教程
