首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

imagepolygon

(PHP 4, PHP 5, PHP 7)

imagepolygon - 绘制一个多边形

描述

代码语言:javascript
复制
bool imagepolygon ( resource $image , array $points , int $num_points , int $color )

imagepolygon()在给定中创建一个多边形image

参数

代码语言:txt
复制
`image`   

一个图像资源,由图像创建函数之一返回,如imagecreatetruecolor()。

points

包含多边形顶点的数组,例如:

points0

= x0

points1

= y0

points2

= x1

points3

= y1

num_points

点(顶点)的总数。

color

使用imagecolorallocate()创建的颜色标识符。

返回值

返回TRUE成功或失败时返回FALSE

例子

Example #1 imagepolygon() example

代码语言:javascript
复制
<?php
//?Create?a?blank?image
$image?=?imagecreatetruecolor(400,?300);

//?Allocate?a?color?for?the?polygon
$col_poly?=?imagecolorallocate($image,?255,?255,?255);

//?Draw?the?polygon
imagepolygon($image,?array(
????????0,???0,
????????100,?200,
????????300,?200
????),
????3,
????$col_poly);

//?Output?the?picture?to?the?browser
header('Content-type:?image/png');

imagepng($image);
imagedestroy($image);
?>

上面的例子会输出类似于:

← imagepng

imagepsbbox →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com