php生成平行四边形

来源:百度知道 编辑:UC知道 时间:2024/05/14 14:50:44
php如何生成平行四边形,填充平行四边形

<?php
// 建立多边形各顶点坐标的数组
$values = array(
40, 50, // Point 1 (x, y)
20, 150, // Point 2 (x, y)
200, 150, // Point 3 (x, y)
220, 50, // Point 4 (x, y)
);

// 创建图像
$image = imagecreatetruecolor(250, 250);

// 设定颜色
$bg = imagecolorallocate($image, 200, 200, 200);
$blue = imagecolorallocate($image, 0, 0, 255);

// 画一个多边形
imagefilledpolygon($image, $values, 4, $blue);

// 输出图像
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>