php--如何在画布上填充颜色
程序员文章站
2022-07-13 12:51:01
...
<?php
/**
* Created by PhpStorm.
*/
$my_image = imagecreate(330,330);
$white = imagecolorallocate($my_image,255,255,255);
$black = imagecolorallocate($my_image,0,0,0);
$red = imagecolorallocate($my_image,255,0,0);
$green = imagecolorallocate($my_image,0,255,0);
$blue = imagecolorallocate($my_image,0,0,255);
imagefilledrectangle($my_image,10,10,60,110,$red);
imagefilledellipse($my_image,120,65,100,80,$green); // 中心点
imagefilledarc($my_image,200,65,100,80,0,90,$blue,2);
//1=三角形,2=圆弧,3=线段,4=扇形,6=空心扇形,7=空心三角形,
$points = array('10','150','80','230','150','120','240','180');
imagefilledpolygon($my_image,$points,(count($points)/2),$black);
header('Content-type:image/png');
imagepng($my_image);
imagedestroy($my_image);
推荐阅读