/** * Draws a polygon * * Parameter array: * 'connect': bool [optional] Specifies whether the start point should be * connected to the endpoint (closed polygon) or not (connected line) * 'fill': mixed [optional] The fill color * 'line': mixed [optional] The line color * @param array $params Parameter array */ function polygon($params) { if (isset($this->_imageMap)) { $this->_imageMap->polygon($params); } parent::polygon($params); }
/** * Parameter array: * 'connect': bool [optional] Specifies whether the start point should be * connected to the endpoint (closed polygon) or not (connected line) * 'fill': mixed [optional] The fill color * 'line': mixed [optional] The line color * @param array $params Parameter array */ function polygon($params = array()) { $connectEnds = isset($params['connect']) ? $params['connect'] : false; $fillColor = isset($params['fill']) ? $params['line'] : false; $lineColor = isset($params['line']) ? $params['line'] : false; $line = $this->_setLineStyle($lineColor); $fill = false; if ($connectEnds) { $fill = $this->_setFillStyle($fillColor); } $first = true; foreach ($this->_polygon as $point) { if ($first === true) { pdf_moveto($this->_pdf, $point['X'], $point['Y']); $first = $point; } else { if (isset($last['P1X'])) { pdf_curveto($this->_pdf, $last['P1X'], $last['P1Y'], $last['P2X'], $last['P2Y'], $point['X'], $point['Y']); } else { pdf_lineto($this->_pdf, $point['X'], $point['Y']); } } $last = $point; } if ($connectEnds) { if (isset($last['P1X'])) { pdf_curveto($this->_pdf, $last['P1X'], $last['P1Y'], $last['P2X'], $last['P2Y'], $first['X'], $first['Y']); } else { pdf_lineto($this->_pdf, $first['X'], $first['Y']); } } if ($line && $fill) { pdf_fill_stroke($this->_pdf); } elseif ($line) { pdf_stroke($this->_pdf); } elseif ($fill) { pdf_fill($this->_pdf); } parent::polygon($params); }
/** * Draws a polygon * * Parameter array: * 'connect': bool [optional] Specifies whether the start point should be * connected to the endpoint (closed polygon) or not (connected line) * 'fill': mixed [optional] The fill color * 'line': mixed [optional] The line color * 'map_vertices': bool [optional] Specifies whether the image map should map the vertices instead of the polygon as a whole * 'url': string [optional] URL to link the polygon as a whole to (also used for default in case 'map_vertices' is used) * 'alt': string [optional] Alternative text to show in the image map (also used for default in case 'map_vertices' is used) * 'target': string [optional] The link target on the image map (also used for default in case 'map_vertices' is used) * @param array $params Parameter array */ function polygon($params) { if (isset($params['map_vertices']) && $params['map_vertices'] === true) { $mapsize = isset($params['mapsize']) ? $params['mapsize'] : 2; foreach ($this->_polygon as $point) { $vertex_param = $params; if (isset($point['url'])) { $vertex_param['url'] = $point['url']; } if (isset($point['target'])) { $vertex_param['target'] = $point['target']; } if (isset($point['alt'])) { $vertex_param['alt'] = $point['alt']; } $vertex_mapsize = $mapsize; if (isset($point['mapsize'])) { $vertex_mapsize = $point['mapsize']; } if (isset($point['htmltags'])) { $vertex_param['htmltags'] = $point['htmltags']; } $this->_addMapTag('circle', $this->_getX($point['X']) . ',' . $this->_getY($point['Y']) . ',' . $mapsize, $vertex_param); } } else { if (isset($params['url'])) { $points = ''; foreach ($this->_polygon as $point) { if ($points != '') { $points .= ','; } $points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']); } $this->_addMapTag('polygon', $points, $params); } } parent::polygon($params); }
/** * Parameter array: * 'connect': bool [optional] Specifies whether the start point should be * connected to the endpoint (closed polygon) or not (connected line) * 'fill': mixed [optional] The fill color * 'line': mixed [optional] The line color * @param array $params Parameter array */ function polygon($params = array()) { $connectEnds = isset($params['connect']) ? $params['connect'] : false; $fillColor = isset($params['fill']) ? $params['line'] : false; $lineColor = isset($params['line']) ? $params['line'] : false; if (!$connectEnds) { $fillColor = 'transparent'; } $style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor); $first = true; $spline = false; $lastpoint = false; foreach ($this->_polygon as $point) { if ($first) { $points = 'M'; } elseif (!$spline) { $points .= ' L'; } if ($spline && $lastpoint !== false) { $points .= ' ' . round($lastpoint['P1X']) . ',' . round($lastpoint['P1Y']) . ' ' . round($lastpoint['P2X']) . ',' . round($lastpoint['P2Y']); } $points .= ' ' . round($point['X']) . ',' . round($point['Y']); if (isset($point['P1X']) && isset($point['P1Y']) && isset($point['P2X']) && isset($point['P2Y'])) { if ($first || !$spline) { $points .= ' C'; } $lastpoint = $point; $spline = true; } else { $spline = false; } $first = false; } if ($connectEnds) { $point .= ' Z'; } $this->_addElement('<path ' . 'd="' . $points . '" ' . 'style="' . $style . '"' . '/>', $params); parent::polygon($params); }
/** * Parameter array: * 'connect': bool [optional] Specifies whether the start point should be * connected to the endpoint (closed polygon) * or not (connected line) * '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 polygon($params = array()) { $connectEnds = isset($params['connect']) ? $params['connect'] : false; $fillColor = isset($params['fill']) ? $params['fill'] : false; $lineColor = isset($params['line']) ? $params['line'] : false; $lineStyle = $this->_getLineStyle($lineColor); $fillStyle = $this->_getFillStyle($fillColor); $shape = new SWFShape(); if ($connectEnds) { $shape->setRightFill($fillStyle[0], $fillStyle[1], $fillStyle[2]); } $shape->setLine(0, $lineStyle[0], $lineStyle[1], $lineStyle[2]); $shape->movePenTo($this->_polygon[0]['X'], $this->_polygon[0]['Y']); foreach ($this->_polygon as $point) { $shape->drawLineTo($point['X'], $point['Y']); } if ($connectEnds) { $shape->drawLineTo($this->_polygon[0]['X'], $this->_polygon[0]['Y']); } 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); $this->_canvas->add($button); } else { $this->_canvas->add($shape); } parent::polygon($params); }