PHP 中的 imagepolygon() 函数
imagepolygon() 函数用于绘制多边形。
语法
bool imagepolygon( $img, $points, $num_points, $color)
参数
- $img:使用 imagecreatetruecolor() 函数创建一个空图像。
- $points:一个包含多边形顶点的数组。
- $num_points:多边形中的顶点数目。
- $color:使用 imagecolorallocate() 函数创建的颜色标识符。
返回值
如果成功,imagepolygon() 函数返回 TRUE;如果失败,返回 FALSE。
示例
以下是示例
<?php
$img = imagecreatetruecolor(400, 300);
$color = imagecolorallocate($img, 120, 160, 190);
$bgcolor = imagecolorallocate($img, 10, 100, 50);
imagefill($img, 0, 0, $bgcolor);
imagepolygon($img, array(
50, 50,
150, 200,
340, 200
),
3,
$color);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>输出
以下为输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP