/** * Draw a polyline * * Draw any non-filled polygon, filled using the defined color. The color * should be passed as an array with the keys "red", "green", "blue" and * optionally "alpha". Each key should have a value between 0 and 1 * associated. * * The polyline itself is specified as an array of two-tuples, specifying * the x and y coordinate of the point. * * The thrid parameter defines the width of the border and the last * parameter may optionally be set to false to not close the polygon (draw * another line from the last point to the first one). * * @param array $points * @param array $color * @param float $width * @param bool $close * @return void */ public function drawPolyline(array $points, array $color, $width, $close = true) { $style = array('width' => $width, 'color' => array('r' => $color['red'] * 255, 'g' => $color['green'] * 255, 'b' => $color['blue'] * 255)); // Draw all lines of the polygon. We cannot use the "polygon()" method // in TCPDF, because it _always_ closes the polygon. $last = null; foreach ($points as $point) { if ($last !== null) { $this->document->line($last[0], $last[1], $point[0], $point[1], $style); } $last = $point; } // Draw closing line in polygon if ($close) { $first = reset($points); $this->document->line($last[0], $last[1], $first[0], $first[1], $style); } }