<?php
//1.创建画布
$image = imagecreatetruecolor(300,300);
//2.创建颜色
$red = imagecolorallocate($image,255,0,0); //imagecolorallocate( resource $image, int $red, int $green, int $blue)
$green = imagecolorallocate($image,0,255,0);
$blue = imagecolorallocate($image,0,0,255);
//3.用GD库给咱们函数画画
imageline($image,0,0,300,300,$red); //bool imageline( resource $image, int $x1, int $y1, int $x2, int $y2, int $color)
imagefilledrectangle($image,0,0,400,400,$green);//imagefilledrectangle( resource $image, int $x1, int $y1, int $x2, int $y2, int $color)
imageellipse($image,50,50,100,100,$blue);//imageellipse( resource $image, int $cx, int $cy, int $width, int $height, int $color)
//4.告诉浏览器你的mime类型
header('Content-type:image/png');
//5.输出到浏览器或者可以存放到本地
imagepng($image);//bool imagepng( resource $image[, string $filename] )
//6.销毁资源
imagedestroy($image);
php入门:GD库上
最新推荐文章于 2023-05-16 22:45:06 发布