function drawPie($centerX, $centerY, $radius, $begin, $end, $style) { $this->_convertPosition($centerX, $centerY); $radius = $radius * min($this->width, $this->height); ps_setcolor($this->ps, 'stroke', $style['line'][0], $style['line'][1], $style['line'][2], $style['line'][3], $style['line'][4]); if (isset($style['fill'])) { ps_setcolor($this->ps, 'fill', $style['fill'][0], $style['fill'][1], $style['fill'][2], $style['fill'][3], $style['fill'][4]); } ps_setlinewidth($this->ps, $style['line-width']); ps_moveto($this->ps, $centerX, $centerY); ps_arc($this->ps, $centerX, $centerY, $radius, $begin, $end); ps_lineto($this->ps, $centerX, $centerY); ps_closepath($this->ps); if (isset($style['fill'])) { ps_fill_stroke($this->ps); } else { ps_stroke($this->ps); } }
/** * 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 * @param array $params Parameter array */ function ellipse($params) { $x = $params['x']; $y = $params['y']; $rx = $params['rx']; $ry = $params['ry']; $fillColor = isset($params['fill']) ? $params['fill'] : false; $lineColor = isset($params['line']) ? $params['line'] : false; $line = $this->_setLineStyle($lineColor); $fill = $this->_setFillStyle($fillColor); if ($line || $fill) { if ($rx == $ry) { ps_circle($this->_ps, $this->_getX($x), $this->_getY($y), $rx); } else { ps_moveto($this->_ps, $this->_getX($x - $rx), $this->_getY($y)); ps_curveto($this->_ps, $this->_getX($x - $rx), $this->_getY($y), $this->_getX($x - $rx), $this->_getY($y - $ry), $this->_getX($x), $this->_getY($y - $ry)); ps_curveto($this->_ps, $this->_getX($x), $this->_getY($y - $ry), $this->_getX($x + $rx), $this->_getY($y - $ry), $this->_getX($x + $rx), $this->_getY($y)); ps_curveto($this->_ps, $this->_getX($x + $rx), $this->_getY($y), $this->_getX($x + $rx), $this->_getY($y + $ry), $this->_getX($x), $this->_getY($y + $ry)); ps_curveto($this->_ps, $this->_getX($x), $this->_getY($y + $ry), $this->_getX($x - $rx), $this->_getY($y + $ry), $this->_getX($x - $rx), $this->_getY($y)); } if ($line && $fill) { ps_fill_stroke($this->_ps); } elseif ($line) { ps_stroke($this->_ps); } elseif ($fill) { ps_fill($this->_ps); } } parent::ellipse($params); }