php imagearc,php函数平面坐标系

php绘图 函数平面坐标简易demo

$x_count=50;//x的数字长度

$y_count=50;//y的数字长度

$c=1;//原始单位1

$xc=1;//x坐标单位(倍数)

$yc=1;//y坐标单位(倍数)

$rate=10;//原始单位1的像素间隔

$w=$x_count*$rate;//坐标总宽

$h=$y_count*$rate;//坐标总高

$xo_count=25;//坐标原点(相对于0.0的数字长度)

$yo_count=25;//坐标原点(相对于0.0的数字长度)

$xo=$xo_count*$rate;//坐标原点(相对于0.0的像素)

$yo=$yo_count*$rate;//坐标原点(相对于0.0的像素)

$width=$w+1;

$height=$h+1;

$fun='$result=0.1*$m*$m;';//已$m

$x_cell=$c*$xc;//x单位

$y_cell=$c*$yc;//y单位

$x_pixel=$x_cell*$rate;//x单位像素

$y_pixel=$y_cell*$rate;//y单位像素

//绘图技术 基本步骤 前提:在php.ini文件中启用gd库

//创建画布 默认背景是黑色的

$img=imagecreatetruecolor($width,$height);

//绘制各种图形

//创建一个颜色

$background = imagecolorallocate($img, 255, 255, 255);

$color= imagecolorallocate($img, 255, 0, 255);

//画圆

//imageellipse($img,60,100,50,50,$background);

//椭圆

//imageellipse($img,60,180,50,30,$background);

//画直线

imageline($img,$xo,0,$xo,$height,$background);

imageline($img,0,$yo,$width,$yo,$background);

for($i=0;$i<=$w;$i+=$x_pixel){//宽

imageline($img,$xo+$i,$yo,$xo+$i,$yo-3,$background);

imagestring ($img , 1 , $xo+$i -3, $yo+7 , (string)$i/$x_pixel, $background );

if($i!=0){

imageline($img,$xo-$i,$yo,$xo-$i,$yo-3,$background);

imagestring ($img , 1 , $xo-$i -3, $yo+7 , (string)-$i/$x_pixel, $background );

}

}

for($i=0;$i<=$h;$i+=$y_pixel){//高

imageline($img,$xo,$yo+$i,$xo+3,$yo+$i,$background);

imagestring ($img , 1 , $xo-15 , $yo+$i-7 , (string)$i/$y_pixel, $background );

if($i!=0){

imageline($img,$xo,$yo-$i,$xo+3,$yo-$i,$background);

imagestring ($img , 1 , $xo-15 , $yo-$i-7 , (string)-$i/$y_pixel, $background );

}

}

draw($fun,$img,$color,$rate,$w,$xo,$yo);

//画矩形

//imagerectangle ($img, 400 , 200 , 600 , 80 , $background);

//填充矩形

//imagefilledrectangle ($img, 400 , 400 , 600 , 300 , $background);

//画弧线

//imagearc($img, 100, 300, 150, 150, 180, 270, $background);

//画扇型 IMG_ARC_CHORD直线连接了起始和结束点 IMG_ARC_PIE

//imagefilledarc($img, 100, 400, 150, 150, 180, 270, $background,IMG_ARC_PIE);

//拷贝图片到画布

//$scrImg=imagecreatefromgif('http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif');

//$scrImgInfo=getimagesize('http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif');

// imagecopy ($img,$scrImg,10,450,0,0,$scrImgInfo[0],$scrImgInfo[1]);

//imagecopy ($img,$scrImg,10,10,0,0,270,129);

//写字

//imagestring ($img , 5 , 20 , 20 , 'x:'.$xc, $background );

//imagestring ($img , 5 , 20 , 40 , 'y:'.$yc, $background );

//写中文

$str="PHP绘画技术";

// imagettftext ($img , 30 , 0 , 200 ,50, $background , "MSYHBD.TTF" , $str);

//输出图像到网页(或者另存为)

header("content-type: image/png");

imagepng($img);

//销毁该图片(释放内存)

imagedestroy($img);

function draw($fun,$img,$color,$rate,$w,$xo,$yo){

//$w=200;

for($i=0;$i<=$w;$i+=1){

$result=0;

$x= +$i;

$a=$x/$rate;

$m=$a;

//print_r($m);

eval($fun);

$b=$result;

$y=$b*$rate;

$xi = $x-1;

$ai=$xi/$rate;

$m=$ai;

eval($fun);

$bi=$result;

$yi=$bi*$rate;

imageline($img,$xo+$x,$yo-$y,$xo+$xi,$yo-$yi,$color);

$result=0;

$x= -$i;

$a=$x/$rate;

//print_r($x);

$m=$a;

eval($fun);

$b=$result;

$y=$b*$rate;

$xi = $x+1;

$ai=$xi/$rate;

$m=$ai;

eval($fun);

$bi=$result;

$yi=$bi*$rate;

imageline($img,$xo+$x,$yo-$y,$xo+$xi,$yo-$yi,$color);

//imagesetpixel($img,$x+400,$y+300,$color) ;

}

//print_r($a);die;

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值