php绘图

<?php
/**
 * Created by PhpStorm.
 * User: dllo
 * Date: 16/8/12
 * Time: 下午3:56
 */
header("Content-type: image/jpeg");
$im  = imagecreatetruecolor(100, 100);
$w   = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);

/* 画一条虚线,5 个红色像素,5 个白色像素 */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);

/* 用 imagesetbrush() 和 imagesetstyle 画一行笑脸 */
$style = array($w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $red);
imagesetstyle($im, $style);

$brush = imagecreatefrompng("http://www.libpng.org/pub/png/images/smile.happy.png");
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($im, $brush);
imageline($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);

imagejpeg($im);
imagedestroy($im);
展开阅读全文

php绘图,请高人修改。。

09-27

[code=php]$zuidashujuzhi) $zuidashujuzhi=$shuju[$i];rnrn//计算图像宽度 rn$img_kuan=$zuo+$you+$jiange+count($shuju)*($kuan+$jiange);rn//图像高 rn$img_gao=170;rn//存储色柱高度的数组rn$zhugaodu = array();rn$image = imagecreate($img_kuan,$img_gao);rn$white = imagecolorallocate($image, 0xEE, 0xEE, 0xEE);rn//色柱颜色rn$shuju_yanse =array(rnimagecolorallocate($image, 0x97, 0xbd, 0x00),rnimagecolorallocate($image, 0x00, 0x99, 0x00),rnimagecolorallocate($image, 0xcc, 0x33, 0x00),rnimagecolorallocate($image, 0xff, 0xcc, 0x00),rnimagecolorallocate($image, 0x33, 0x66, 0xcc),rnimagecolorallocate($image, 0x33, 0xcc, 0x33),rnimagecolorallocate($image, 0xff, 0x99, 0x33),rnimagecolorallocate($image, 0xcc, 0xcc, 0x99),rnimagecolorallocate($image, 0x99, 0xcc, 0x66),rnimagecolorallocate($image, 0x66, 0xff, 0x99)rn);rnrnrnrn//坐标轴颜色rn$zuobiao_yanse = imagecolorallocate($image, 0x00, 0x00, 0x00);rn//横轴rnimageline ( $image, $zuo, $img_gao-$xia, $img_kuan-$you/2, $img_gao-$xia, $zuobiao_yanse);rn//纵轴rnimageline ( $image, $zuo, $shang/2, $zuo, $img_gao-$xia, $zuobiao_yanse);rnrnrnrn//纵轴刻度,纵轴上共标注4个点,所以这里分别计算即可rnimageline ( $image, $zuo, $shang, $zuo+6, $shang, $zuobiao_yanse);rnimagestring ( $image, 3, $zuo/4, $shang,round($zuidashujuzhi), $zuobiao_yanse);rnimageline ( $image, $zuo, $shang+($img_gao-$shang-$xia)*1/4, $zuo+6, round($shang+($img_gao-$shang-$xia)*1/4), $zuobiao_yanse);rnimagestring ( $image, 3, $zuo/4, $shang+($img_gao-$shang-$xia)*1/4,round($zuidashujuzhi*3/4), $zuobiao_yanse);rnimageline ( $image, $zuo, $shang+($img_gao-$shang-$xia)*2/4, $zuo+6, $shang+($img_gao-$shang-$xia)*2/4, $zuobiao_yanse);rnimagestring ( $image, 3, $zuo/4, $shang+($img_gao-$shang-$xia)*2/4,round($zuidashujuzhi*2/4), $zuobiao_yanse);rnimageline ( $image, $zuo, $shang+($img_gao-$shang-$xia)*3/4, $zuo+6, $shang+($img_gao-$shang-$xia)*3/4, $zuobiao_yanse);rnimagestring ( $image, 3, $zuo/4, $shang+($img_gao-$shang-$xia)*3/4,round($zuidashujuzhi*1/4), $zuobiao_yanse);rnrnrnrn//得到每个柱的高度rnfor($i=0;$i[/code]rnrn这样子可以生成rn[img=https://img-bbs.csdn.net/upload/201309/27/1380270058_225931.jpg][/img]rnimg.php?a=5.4,2,30.2,4,0,6,7.7,3.8,2,3,4rn用下面这个参数可以得到上面的图片。。rn我现在想获取到比如5.4里面,我又分成三个属性,并且显示每个立柱的名字,请问该如何改进代码。rnrn[img=https://img-bbs.csdn.net/upload/201309/27/1380270462_604755.jpg][/img]rn并且下面的类型个数不限制,比如有钢管,铝管,铜管,金管,。。。。。有若干个。rn但是属性只有三个。。。。每个都为整数。。。rnrn求高人给帮忙修改一下代码,或者给我一个简便的代码。。感谢了。 论坛

没有更多推荐了,返回首页