创建图像。

<?php
//php创建图像

//步骤:
//1、创建画布
$img=imagecreatetruecolor(500,300);

//2、准备颜色:
$white=imagecolorallocate($img,255,255,255);
$black=imagecolorallocate($img,0,0,0);
$red=imagecolorallocate($img,255,0,0);
$green=imagecolorallocate($img,0,255,0);
$blue=imagecolorallocate($img,0,0,255);
$gray=imagecolorallocate($img,200,200,200);


//3、在画布上画图像或文字
//填充灰色
imagefill($img,0,0,$gray);
//在画布上画一个蓝色的圆
imagefilledellipse($img,255,150,200,200,$blue);

//4、输出图像或保存图像
header('Content-Type:image/jpeg');
imagejpeg($img);//保存图像
//imagejpeg($img,'a.jpg');保存到当前路径,图片名为a.jpg

//5、释放画布资源
imagedestroy($img);


?>


?>

 绘制图像:

1.填充画布

imagefill();

2.画一个像素

imagesetpixel(;

3.画线

imageline();

4.画一个矩形

imagerectangle(;

5.画一矩形并填充

imagefilledrectangle(;

6.画一个多边形

imagepolygon();

7.画一个多边形并填充

imagefilledpolygon();

8.画一个椭圆

imageellipse();

9.画一个椭圆并填充

imagefilledellipse();

10.画一个椭圆弧

imagearc();

11.画一个椭圆弧并填充

imagefilledarc();

12.画字符串

imagettftext();
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值