通行证: 用户 密码 域名空间  下载中心 社区论坛 信息公告 my小屋
联系我们
设为首页
加入收藏

 

qq,asp,php,jsp,xml,sql,.net,编程 程序 网页图象 建站经验 私服
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿
论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图
专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版
社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务
当前位置:首页>>在线服务>>疑难解答>>正文 新版上线![旧版]
注:打开慢时请稍等

伪3d绘图类

http://www.iyit.net  日期:2006-10-6 15:30:34  来源:iyit.net收集  点击:
参加讨论
<?php  
class  graph  {  
   /**  
     *  伪3d绘图类  
     */  
   var  $im;  
   var  $type  =  "gif";  //  png,gif,jpeg,wbmp  
   var  $xo;  
   var  $yo;  
   var  $color;  
   var  $fillcolor;  
   var  $filldarkcolor;  
   var  $filltype  =  true;  
   var  $orgx;  
   var  $orgy;  
   var  $viewx;  
   var  $viewy;  
   var  $winx;  
   var  $winy;  
   var  $extx  =  1;  
   var  $exty  =  -1;  
   var  $ksin;  
   var  $kcos;  
 
   function  graph()  {  
           if(func_num_args()  ==  2)  
                       $this->create(func_get_arc(0),func_get_arc(1));  
   }  
   /**  
     *  在($x,$y)处画点  
     */  
   function  pixel($x,$y)  {  
           $p  =  $this->get_view($x,$y);  
           imagesetpixel($this->im,$p[x],$p[y],$this->color);  
           $this->xo  =  $p[x];  
           $this->yo  =  $p[y];  
   }  
   /**  
     *  移动到($x,$y)处  
     */  
   function  moveto($x,$y)  {  
           $p  =  $this->get_view($x,$y);  
           $this->xo  =  $p[x];  
           $this->yo  =  $p[y];  
   }  
   /**  
     *  从($x1,$y1)到($x2,$y2)处画线  
     */  
   function  line($x1,$y1,$x2,$y2)  {  
           $p1  =  $this->get_view($x1,$y1);  
           $p2  =  $this->get_view($x2,$y2);  
           imageline($this->im,$p1[x],$p1[y],$p2[x],$p2[y],$this->color);  
   }  
   /**  
     *  从当前位置到($x,$y)处画线  
     */  
   function  lineto($x,$y)  {  
           $p  =  $this->get_view($x,$y);  
           imageline($this->im,  $this->xo,  $this->yo,  $p[x],  $p[y],  $this->color);  
           $this->xo  =  $p[x];  
           $this->yo  =  $p[y];  
   }  
   /**  
     *  设置当前颜色  
     */  
   function  color($clr)  {  
           $r  =  ($clr>>16)  &  0xff;    
           $g  =  ($clr>>8)  &  0xff;    
           $b  =  ($clr)  &  0xff;    
           $this->color  =  imagecolorallocate($this->im,  $r,$g,$b);  
           $this->fillcolor  =  imagecolorallocate($this->im,  $r,$g,$b);  
           $this->filldarkcolor  =  imagecolorallocate($this->im,  $r/2,$g/2,$b/2);  
           return  $this->color;  
   }  
   /**  
     *  设置当前充填颜色  
     */  
   function  fillcolor($clr)  {  
           $r  =  ($clr>>16)  &  0xff;    
           $g  =  ($clr>>8)  &  0xff;    
           $b  =  ($clr)  &  0xff;    
           $this->fillcolor  =  imagecolorallocate($this->im,  $r,$g,$b);  
           return  $this->fillcolor;  
   }  
   /**  
     *  创建gd句柄并设置坐标系  
     */  
   function  create($x,$y)  {  
           $this->im  =  imagecreate($x,$y);  
           $this->viewx  =  $x-1;  
           $this->viewy  =  -($y-1);  
           $this->winx  =  $x;  
           $this->winy  =  $y;  
           $this->orgx  =  0;  
           $this->orgy  =  0;//$y;  
           $this->colors  =  $this->color(0xffffff);  
 
           settype($this->ksin,"double");  
           settype($this->kcos,"double");  
           $this->ksin  =  sin(deg2rad(0));  
           $this->kcos  =  cos(deg2rad(0));  
   }  
   /**  
     *  坐标映射  
     */  
   function  get_view($x,$y)  {  
           $this->xo  =  $x*$this->kcos  -  $y*$this->ksin;  
           $this->yo  =  $x*$this->ksin  +  $y*$this->kcos;  
           $p[x]  =  ($this->xo  +  $this->orgx)*($this->viewx/$this->winx);  
           $p[y]  =  ($this->yo  +  $this->orgy)*($this->viewy/$this->winy)-$this->viewy;  
           return  $p;  
   }  
   /**  
     *  设置限度  
     */  
   function  set_ext($x,$y=0)  {  
           $this->winx  =  $x;  
           if($y  ==  0)  {  
                       $this->winy  =  -  $x  *  $this->viewy  /  $this->viewx;  
           }else  {  
                       $this->winy  =  $y;  
           }  
   }  
   /**  
     *  设置旋转角  
     */  
   function  set_r($p)  {  
           $this->ksin  =  sin(deg2rad($p));  
           $this->kcos  =  cos(deg2rad($p));  
   }  
   /**  
     *  构造图形,必需在派生类中重载本方法  
     */  
   function  paint()  {  
           /**  
             *  必需由派生类重载  
             *  必需包含语句  $this->create(宽度,高度);  
             */  
           die("paint  方法必需由派生类重载!");  
   }  
   /**  
     *  输出图形  
     */  
   function  run()  {  
           $this->paint();  
           $func  =  "image".$this->type;  
           if(!  function_exists($func))  {  
                       $this->type  =  "png";  
                       $func  =  "image".$this->type;  
           }  
           header("content-type:  image/{$this->type}");  
           $func($this->im);  
           imagedestroy($this->im);  
   }  
 
   /**  
     *  圆类图形数据生成,参数$p为坐标旋转角  
     */  
   function  get_point($ox,$oy,$w,$h,$start,$end)  {  
           $a  =  $w/2;  
           $b  =  $h/2;  
           $rs  =  array();  
           $i  =  $start;  
           for($i=$start;$i<=$end;$i+=5)  {  
                       $n  =  deg2rad($i);  
                       $x  =  $a*cos($n);  
                       $y  =  $b*sin($n);  
                       $p  =  $this->get_view($ox+$x,$oy+$y);  
                       $rs[]  =  $p[x];  
                       $rs[]  =  $p[y];  
                       if($i  ==  $end)  break;  
                       if($i+5  >  $end)  $i  =  $end  -  5;  
           }  
           $p  =  $this->get_view($ox,$oy);  
           $rs[]  =  $p[x];  
           $rs[]  =  $p[y];  
           $rs[]  =  $rs[0];  
           $rs[]  =  $rs[1];  
           return  $rs;  
   }  
   /**  
     *  弓形  
     */  
   function  chord($left,$top,$w,$h,$start,$end,$z=0)  {  
           $ar  =  $this->get_point($left,$top,$w,$h,$start,$end,$p);  
           for($i=0;$i<count($ar);$i+=2)  {  
                       $p  =  $this->get_view($ar[$i],$ar[$i+1]);  
                       $ar[  
---------------------------------------------------------------  
 
具体是什么错?  
---------------------------------------------------------------  
 
up  
---------------------------------------------------------------  
 
我不懂php﹐不過想接分  
---------------------------------------------------------------  
 
好东东,先试一试看看。  
 
 
---------------------------------------------------------------  
 
php是个有意思的东西,希望她一路走好  
---------------------------------------------------------------  
 
我的居然提示:  
php  fatal  error:  call  to  undefined  function:  imagecreate()  in  e:\jysweb\office\test\class.php  on  line  89    
 
要配置......  
 
 
---------------------------------------------------------------  
 
这么长的代码,找错真是难啊:)恭喜楼主  
---------------------------------------------------------------  
 
php.ini  
 
extension=php_gd.dll  
---------------------------------------------------------------  
 
这段代码我测试过了,本身没有什么错误!  
 
图像是一个立体饼状图,切成了3块,还有一个十字架,左下角还有一个小桶  
 
p.s.我的gd不支持gif,所以我用了png图  
---------------------------------------------------------------  
 
不过这个类确实写得很精致,堪称经典代码!  
---------------------------------------------------------------  
 
up  
---------------------------------------------------------------  
 
up  
---------------------------------------------------------------  
 
up  
---------------------------------------------------------------  
 
up  
---------------------------------------------------------------  
 
呵呵,每次来都可以看见楼主的身影,恭喜!  
---------------------------------------------------------------  
 
呵呵,我一运行,没晕死,出了不到10000行错误。  
notice:  use  of  undefined  constant  x  -  assumed  'x'  in  /home/yjj/public_html/temp/test/index.php  on  line  109  
 
notice:  use  of  undefined  constant  y  -  assumed  'y'  in  /home/yjj/public_html/temp/test/index.php  on  line  110  
 
notice:  use  of  undefined  constant  x  -  assumed  'x'  in  /home/yjj/public_html/temp/test/index.php  on  line  109  
 
notice:  use  of  undefined  constant  y  -  assumed  'y'  in  /home/yjj/public_html/temp/test/index.php  on  line  110  
 
notice:  use  of  undefined  constant  x  -  assumed  'x'  in  /home/yjj/public_html/temp/test/index.php  on  line  169  
 
notice:  use  of  undefined  constant  y  -  assumed  'y'  in  /home/yjj/public_html/temp/test/index.php  on  line  170  
全是这个.  
---------------------------------------------------------------  
 
楼主很热心,恭喜~  
---------------------------------------------------------------  
 
可能是里面的计算,精度不够。  
 
直接整除了  
---------------------------------------------------------------  
 
呵呵,我一运行,没晕死,出了不到10000行错误。  
notice:  use  of  undefined  constant  x  -  assumed  'x'  in  /home/yjj/public_html/temp/test/index.php  on  line  109  
 
notice:  use  of  undefined  constant  y  -  assumed  'y'  in  /home/yjj/public_html/temp/test/index.php  on  line  110  
 
notice:  use  of  undefined  constant  x  -  assumed  'x'  in  /home/yjj/public_html/temp/test/index.php  on  line  109  
 
notice:  use  of  undefined  constant  y  -  assumed  'y'  in  /home/yjj/public_html/temp/test/index.php  on  line  110  
 
notice:  use  of  undefined  constant  x  -  assumed  'x'  in  /home/yjj/public_html/temp/test/index.php  on  line  169  
 
notice:  use  of  undefined  constant  y  -  assumed  'y'  in  /home/yjj/public_html/temp/test/index.php  on  line  170  
全是这个.  
 
---------------------------------------------------------------  
 
congratulation!  
i  want  to  try,but  i  can't  understand  the  above-mentioned  code.  
---------------------------------------------------------------  
 
太长了,头晕。  
---------------------------------------------------------------  
 
呵呵  
---------------------------------------------------------------  
 
不会。  
---------------------------------------------------------------  
 
碰到高人了,快帮我,  
用gd画好的图用  
header("content-type:image/png");  
imag

编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部]
上一篇:怎么在网页中内嵌netmeeting?请教高手,谢谢!!
下一篇:怎么获得程序所在的当前文件夹的名称!
转载请注明来源:www.iyit.net
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

 相关文章
最新更新 热点排行 推荐新闻
我在windows  xp上安装apache2.044+ph
apache+php,怎样打开session支持??
在linux中怎么配置pdflib和php  高分!
怎么样同时解释.php和.php3的文件呀,
php 4.1.0 及以后版本使用post变量的接
我在windows  xp上安装apache2.044+ph
apache+php,怎样打开session支持??
在linux中怎么配置pdflib和php  高分!
怎么样同时解释.php和.php3的文件呀,
php 4.1.0 及以后版本使用post变量的接
apache2-win32+php的成功安装方法
我只是想在本地机上学习php ,还要安装
装了php。运行时出现在以下提示
如何安装apache2.0
怎么删除mysql???
我在windows  xp上安装apache2.044+ph
apache+php,怎样打开session支持??
如何实现注册时的确认码功能
请帮忙解决,图随机上传,不限量,定位
有没有很好方法,获得在线登陆用户名单
qq密码被盗怎么办!我教你找回密码
如何控制我的电脑只允许登录我自己的q
qq2006 beta3隆重发布 实用功能一一奉
美国微软总部相中重庆15岁网络奇才(图
百度声明称遭受有史以来最大规模黑客攻
被删除系统文件恢复全攻略
使用身份验证来禁止内部用户上网 
国内首次发现带有感染文件特征盗号病毒
06年08月31日石家庄太和 内存报价
用css控制透明图片 
exeplorer.exe错误的问题的总结、解决
三分钟让你的系统变处女:acronis tru
让你的密码成为黑客的“耻辱”
比较sql server2005和oracle 10g r2
比较sql server2005和oracle 10g r2
sql server2005的xml数据类型之基础篇
sql server服务器的“偷梁换柱”
在win2003下mysql数据库每天自动备份
win2000 apache php mysql 安装及安全
mysql账户相关
快速安装windows操作系统独家秘籍
 友情链接
设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
copyrights © 2004-2006 iyit.net all rights reserved.
网站合作、广告联系qq:147007642、466949678
易特网络技术 点击这里给我发消息