导航:首页 > 编程语言 > Php画图生成图片

Php画图生成图片

发布时间:2023-04-24 17:01:37

1. php的gd函数画图问题

这是我写的,运用数学方面多一点,没有代码的技巧。

function draw_five_star($image, $x, $y, $r, $color) {
$apexs = array();
$apexs[] = $x;
$apexs[] = $y;

$angle = (2*pi())/5;
$xa = $r * cos($angle) * tan($angle/2);
$ya = $r - $r * cos($angle);

$apexs[] = $x - $xa;
$apexs[] = $y + $ya;

$xb = $r * sin($angle);
$yb = $ya;
$apexs[] = $x - $xb;
$apexs[] = $y + $yb;

$xyr = $xa/sin($angle/2);

$xc = $xyr * cos($angle/4);
$yc = $r + $xyr * sin($angle/4);

$apexs[] = $x - $xc;
$apexs[] = $y + $yc;

$xd = $r * sin($angle/2);
$yd = $r + $r * cos($angle/2);

$apexs[] = $x - $xd;
$apexs[] = $y + $yd;

$xe = 0;
$ye = $r + $xyr;

$apexs[] = $x - $xe;
$apexs[] = $y + $ye;

$xf = $xd;
$yf = $yd;

$apexs[] = $x + $xf;
$apexs[] = $y + $yf;

$xg = $xc;
$yg = $yc;

$apexs[] = $x + $xg;
$apexs[] = $y + $yg;

$xh = $xb;
$yh = $yb;

$apexs[] = $x + $xh;
$apexs[] = $y + $yh;

$xi = $xa;
$yi = $ya;

$apexs[] = $x + $xi;
$apexs[] = $y + $ya;

imagefilledpolygon($image, $apexs, 10, $color);
}
draw_five_star($image, 125, 30, 100, $red);

2. php gd库如何画出以下的对话图,或用其他画图

说实话,用php画会很麻烦,最好在前段用css3实现,对话气泡可以用一个border-radius的圆角div来实现,再加个box-shadow弄点儿阴影就 可以了。设置width固定,height自动,接收到的消息框,float为left,发送的为right。

3. php怎么用星号画图

搜索引擎爬去我们页面的工具叫做搜索引擎机器人,也生动的叫做“蜘蛛”

蜘蛛在爬去网站页面之前,会先去访问网站根目录下面的一个文件,就是robots.txt。这个文件其实就是给“蜘蛛”的规则,如果没有这个文件,蜘蛛会认为你的网站同意全部抓取网页。

Robots.txr文件是一个纯文本文件,可以告诉蜘蛛哪些页面可以爬取(收录),哪些页面不能爬取。

举个例子:建立一个名为robots.txt的文本文件,然后输入User-agent: * 星号说明允许所有搜索引擎收录Disallow: index.php? 表示不允许收录以index.php?前缀的链接,比如index.php?=865Disallow: /tmp/ 表示不允许收录根目录下的tmp目录,包括目录下的文件,比如tmp/232.html

4. PHP画图的问题,急求~~~

1、php画图需要使用GD库,首先需要设置支持GD。
2、支持GD后,用imageline()画线。
3、如果想给线加颜色在使用imagecolorallocate()调整线的颜色。
4、画的时候没有什么先后顺序,先画哪个都可以,画出来之后调整一下布局就可以了。
5、如果对画线的用法不太清除,多看看手册,讲的很详细。
6、实在不行就网络,有很多实例。

以上,希望能帮到你。

5. php怎么输出背景透明的图片

php可以使用GD库或者ImageMagick工具生成png或者gif的背景透明图片.推荐使用ImageMagick.
这里有范例 http://php.net/manual/en/imagick.examples-1.php
准备一张png图片,放到php文件的目录,运行看看效果.
<?php
/* Read the image */
$im = new Imagick("test.png");
/* Thumbnail the image */
$im->thumbnailImage(200, null);

/* Create a border for the image */
$im->borderImage(new ImagickPixel("white"), 5, 5);

/* Clone the image and flip it */
$reflection = $im->clone();
$reflection->flipImage();

/* Create gradient. It will be overlayed on the reflection */
$gradient = new Imagick();

/* Gradient needs to be large enough for the image and the borders */
$gradient->newPseudoImage($reflection->getImageWidth() + 10, $reflection->getImageHeight() + 10, "gradient:transparent-black");

/* Composite the gradient on the reflection */
$reflection->compositeImage($gradient, imagick::COMPOSITE_OVER, 0, 0);

/* Add some opacity. Requires ImageMagick 6.2.9 or later */
$reflection->setImageOpacity( 0.3 );

/* Create an empty canvas */
$canvas = new Imagick();

/* Canvas needs to be large enough to hold the both images */
$width = $im->getImageWidth() + 40;
$height = ($im->getImageHeight() * 2) + 30;
$canvas->newImage($width, $height, new ImagickPixel("black"));
$canvas->setImageFormat("png");

/* Composite the original image and the reflection on the canvas */
$canvas->compositeImage($im, imagick::COMPOSITE_OVER, 20, 10);
$canvas->compositeImage($reflection, imagick::COMPOSITE_OVER, 20, $im->getImageHeight() + 10);

/* Output the image*/
header("Content-Type: image/png");
echo $canvas;
?>

6. php画图 怎么画平行四边形

PHP没有绘制平行四边形的函数。
你可以用imageline一条线一条线的链接,正如楼上这位所说。但是你也可以用imagepolygon(绘制多边形)。

<?php
// 创建真彩色画布
$image = imagecreatetruecolor(400, 300);

// 填充画布颜色
$bg = imagecolorallocate($image, 0, 0, 0);

// 多边形的颜色
$col_poly = imagecolorallocate($image, 255, 255, 255);

// 绘制多边形
imagepolygon($image,
array (
0, 0,
50, 100,
250, 100,
200, 0
),
3,
$col_poly);

// 输出图片
header("Content-type: image/png");。

7. 用php画图时出现乱码,代码哪里需要改的吗

这样写
不要有html代码,而且你最后一个还写错了imagegjpeg($im);,应该是imagejpeg($im);header信息最好在上面
<?php
header('Content-Type: image/jpeg');
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagejpeg($im);
?>

阅读全文

与Php画图生成图片相关的资料

热点内容
解压缩exe文件 浏览:62
汽车没有解压行吗 浏览:320
海南省分布式服务器云主机 浏览:31
世纪江湖聊天室源码 浏览:248
阿里网盘的文件如何解压 浏览:781
简单淘宝客源码 浏览:680
煎饼解压视频教程全集 浏览:339
平行线pdf 浏览:631
android锁屏不退出程序运行 浏览:635
sap连接的服务器地址是 浏览:426
linuxshell脚本从入门到精通 浏览:725
python进制均值 浏览:629
pdfformac 浏览:318
用虚拟服务器是什么目的 浏览:192
压缩机阿里巴巴 浏览:637
主图指标源码回踩 浏览:161
怎么验证服务器端口 浏览:612
如何添加密码卡 浏览:671
2021好声音在哪个app观看 浏览:126
压缩层计算深度 浏览:391