duanbo2048 2011-05-06 12:20
浏览 109

如何在php中绘制带有虚线边框的圆圈?

I want to draw a circle with dashed border. imagearc function can be used for simple border. But I don't get any way for dashed border.

Thanks.

  • 写回答

2条回答 默认 最新

  • douvcpx6526 2011-05-06 12:25
    关注

    here it is

    <?php 
    function dashedcircle($im, $cx, $cy, $radius, $colour, $dashsize=5) { 
    
       $dash=false; 
       for ($angle=0; $angle<=(180+$dashsize); $angle+=$dashsize) { 
          $x = ($radius * cos(deg2rad($angle))); 
          $y = ($radius * sin(deg2rad($angle))); 
    
          if ($dash) { 
             imageline($im, $cx+$px, $cy+$py, $cx+$x, $cy+$y, $colour); 
             imageline($im, $cx-$px, $cx-$py, $cx-$x, $cy-$y, $colour); 
          } 
          $dash=!$dash; 
          $px=$x; 
          $py=$y; 
       } 
    } 
    ?>
    

    one more way of drawing a dashed-line circle.enjoy!

    <?php
    
    header("Content-type: image/jpeg");
    $im = imagecreate(100,100);
    
    $b   = imagecolorallocate ($im, 0, 0, 0);
    $w   = imagecolorallocate ($im, 255, 255, 255);
    
    $style = array ($b,$b,$b,$b,$b,$w,$w,$w,$w,$w);
    
    imagesetstyle ($im, $style);
    
    imagearc($im,50,50,100,100,0,360,IMG_COLOR_STYLED);
    
    imagejpeg($im);
    imagedestroy($im);
    ?>
    

    Reference

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题