<?php
header('content-type:image/png');
//创建画布
$img = imagecreatetruecolor(200,100);
1
//创建颜色
$color =imagecolorallocate($img,255,0,0);
1
//填充区域
imagefill($img,0,0,$color);
$color = imagecolorallocate ($img,0,0,0);
//随机画10个点
for($i=0; $i<10;$i++){
$x =rand(0,200);
$y =rand(0,100);
imagesetpixel($img, $x, $y, $color);
}
//随机画出10条线
$color =imagecolorallocate($img, 0, 0, 255);
for($i=0;$i<10;$i++){
$x1=rand(0,200);
$y1=rand(0,100);
$x2=rand(0,200);
$y2=rand(0,100);
imageline($img, $x1, $y1,$x2,$y2,$color);
}
// imageline()用color颜色在图像image中从坐标x1,y1,到x2,y2(图像左上角为0,0)画一条线段
//画一个矩形
$color =imagecolorallocate($img, 0, 255, 0);
// imagerectangle($img, 50, 50,100,100, $color);
imagefilledrectangle($img, 50, 50, 100, 100, $color);
1
2
3
//输出文字
$text ="hello";
$color =imagecolorallocate($img, 255, 0,255);
$font = "simsunb.ttf";
创建画布及绘制图形文字
最新推荐文章于 2024-01-09 16:36:58 发布