当前位置: 首页>>代码示例>>PHP>>正文


PHP Image_Canvas::drawEnd方法代码示例

本文整理汇总了PHP中Image_Canvas::drawEnd方法的典型用法代码示例。如果您正苦于以下问题:PHP Image_Canvas::drawEnd方法的具体用法?PHP Image_Canvas::drawEnd怎么用?PHP Image_Canvas::drawEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image_Canvas的用法示例。


在下文中一共展示了Image_Canvas::drawEnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: drawEnd

 /**
  * Draw a line end
  *
  * Parameter array:
  * 'x'     : int X point
  * 'y'     : int Y point
  * 'end'   : string The end type of the end
  * 'size'  : int The size of the end
  * 'color' : string The color of the end
  * 'angle' : int [optional] The angle with which to draw the end
  * 'url'   : string [optional] Target URL
  *
  * @param array $params Parameter array
  *
  * @return void
  */
 function drawEnd($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $size = $params['size'];
     $angle = deg2rad(isset($params['angle']) ? $params['angle'] : 0);
     $pi2 = pi() / 2;
     switch ($params['end']) {
         case 'lollipop':
         case 'circle':
             if (($fill = $this->_getFillStyle($params['color'])) !== false) {
                 $shapeObj = new SWFShape();
                 $shapeObj->setRightFill($fill[0], $fill[1], $fill[2]);
                 $shapeObj->movePenTo($x + $size / 2, $y);
                 $shapeObj->drawCircle($size / 2);
                 if (isset($params['url'])) {
                     $button = new SWFButton();
                     $button->addShape($shapeObj, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
                     $button->addAction(new SWFAction("getURL('{$params['url']}');"), SWFBUTTON_MOUSEUP);
                     $this->_canvas->add($button);
                 } else {
                     $this->_canvas->add($shapeObj);
                 }
                 parent::drawEnd($params);
             }
             break;
         case 'diamond':
             $x0 = round($params['x'] + cos($angle) * $size * 0.65);
             $y0 = round($params['y'] - sin($angle) * $size * 0.65);
             $shape = array(array($x0 + round(cos($angle) * $size * 0.65), $y0 - round(sin($angle) * $size * 0.65)), array($x0 + round(cos($angle + $pi2) * $size * 0.65), $y0 - round(sin($angle + $pi2) * $size * 0.65)), array($x0 + round(cos($angle + pi()) * $size * 0.65), $y0 - round(sin($angle + pi()) * $size * 0.65)), array($x0 + round(cos($angle + 3 * $pi2) * $size * 0.65), $y0 - round(sin($angle + 3 * $pi2) * $size * 0.65)));
             break;
         case 'line':
             $shape = array(array($x + round(cos($angle + $pi2) * $size / 2), $y - round(sin($angle + $pi2) * $size / 2)), array($x + round(cos($angle + 3 * $pi2) * $size / 2), $y - round(sin($angle + 3 * $pi2) * $size / 2)));
             break;
         case 'box':
         case 'rectangle':
             $x0 = round($params['x'] + cos($angle) * $size / 2);
             $y0 = round($params['y'] - sin($angle) * $size / 2);
             $pi4 = pi() / 4;
             $shape = array(array($x0 + round(cos($angle + $pi4) * $size / 2), $y0 - round(sin($angle + $pi4) * $size / 2)), array($x0 + round(cos($angle + $pi2 + $pi4) * $size / 2), $y0 - round(sin($angle + $pi2 + $pi4) * $size / 2)), array($x0 + round(cos($angle + pi() + $pi4) * $size / 2), $y0 - round(sin($angle + pi() + $pi4) * $size / 2)), array($x0 + round(cos($angle + 3 * $pi2 + $pi4) * $size / 2), $y0 - round(sin($angle + 3 * $pi2 + $pi4) * $size / 2)));
             break;
         case 'arrow':
             $shape = array(array($x + cos($angle) * $size, $y - sin($angle) * $size), array($x + cos($angle + $pi2) * $size * 0.4, $y - sin($angle + $pi2) * $size * 0.4), array($x + cos($angle + 3 * $pi2) * $size * 0.4, $y - sin($angle + 3 * $pi2) * $size * 0.4));
             break;
         case 'arrow2':
             $shape = array(array($x + round(cos($angle) * $size), $y - round(sin($angle) * $size)), array($x + round(cos($angle + $pi2 + deg2rad(45)) * $size), $y - round(sin($angle + $pi2 + deg2rad(45)) * $size)), array($x, $y), array($x + round(cos($angle + 3 * $pi2 - deg2rad(45)) * $size), $y - round(sin($angle + 3 * $pi2 - deg2rad(45)) * $size)));
             break;
     }
     if (isset($shape)) {
         // output the shape
         if (($fill = $this->_getFillStyle($params['color'])) !== false) {
             $shapeObj = new SWFShape();
             $shapeObj->setRightFill($fill[0], $fill[1], $fill[2]);
             $shapeObj->setLine(0, $fill[0], $fill[1], $fill[2]);
             $shapeObj->movePenTo($shape[0][0], $shape[0][1]);
             for ($count = count($shape); $count--; $count > 0) {
                 $shapeObj->drawLineTo($shape[$count][0], $shape[$count][1]);
             }
             if (isset($params['url'])) {
                 $button = new SWFButton();
                 $button->addShape($shapeObj, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
                 $button->addAction(new SWFAction("getURL('{$params['url']}');"), SWFBUTTON_MOUSEUP);
                 $this->_canvas->add($button);
             } else {
                 $this->_canvas->add($shapeObj);
             }
         }
     }
     parent::drawEnd($params);
 }
开发者ID:roojs,项目名称:pear,代码行数:86,代码来源:SWF.php


注:本文中的Image_Canvas::drawEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。