Exemple #1
0
 /**
  * Draw an ellipse
  *
  * Parameter array:
  * 'x'    : int X center point
  * 'y'    : int Y center point
  * 'rx'   : int X radius
  * 'ry'   : int Y radius
  * 'fill' : mixed [optional] The fill color
  * 'line' : mixed [optional] The line color
  * 'url'  : string [optional] Target URL
  *
  * @param array $params Parameter array
  *
  * @return void
  */
 function ellipse($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $rx = $this->_getX($params['rx']);
     $ry = $this->_getY($params['ry']);
     // calculate scale factors
     $scaleX = 1.0;
     $scaleY = 1.0;
     $moveX = 0;
     $moveY = 0;
     if ($rx > $ry) {
         $scaleY = $ry / $rx;
         $moveY = $ry * (1 - $scaleY);
     } elseif ($rx < $ry) {
         $scaleX = $rx / $ry;
         $moveX = $rx * (1 - $scaleX);
     }
     $fillColor = isset($params['fill']) ? $params['fill'] : false;
     $lineColor = isset($params['line']) ? $params['line'] : false;
     $fillColor = $this->_getFillStyle($fillColor);
     $lineColor = $this->_getLineStyle($lineColor);
     $shape = new SWFShape();
     $shape->setRightFill($fillColor[0], $fillColor[1], $fillColor[2]);
     $shape->movePenTo($x, $y);
     $shape->setLine(1, $lineColor[0], $lineColor[1], $lineColor[2]);
     if (count($fillColor)) {
         $shape->setRightFill($fillColor[0], $fillColor[1], $fillColor[2]);
     }
     $shape->drawCircle(max($rx, $ry));
     if (isset($params['url'])) {
         $button = new SWFButton();
         $button->addShape($shape, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER);
         $button->addAction(new SWFAction("getURL('{$params['url']}');"), SWFBUTTON_MOUSEUP);
         $ellipse = $this->_canvas->add($button);
     } else {
         $ellipse = $this->_canvas->add($shape);
     }
     $ellipse->move($moveX, $moveY);
     $ellipse->scaleTo($scaleX, $scaleY);
     parent::ellipse($params);
 }