LineWidth; $this->SetLineWidth($width); $this->LineWidth = $width_prev; } if (isset($cap)) { $ca = array('butt' => 0, 'round'=> 1, 'square' => 2); if (isset($ca[$cap])) $this->_out($ca[$cap] . ' J'); } if (isset($join)) { $ja = array('miter' => 0, 'round' => 1, 'bevel' => 2); if (isset($ja[$join])) $this->_out($ja[$join] . ' j'); } if (isset($dash)) { $dash_string = ''; if ($dash) { if(ereg('^.+,', $dash)) $tab = explode(',', $dash); else $tab = array($dash); $dash_string = ''; foreach ($tab as $i => $v) { if ($i > 0) $dash_string .= ' '; $dash_string .= sprintf('%.2f', $v); } } if (!isset($phase) || !$dash) $phase = 0; $this->_out(sprintf('[%s] %.2f d', $dash_string, $phase)); } if (isset($color)) { list($r, $g, $b) = $color; $this->SetDrawColor($r, $g, $b); } } // Draws a line // Parameters: // - x1, y1: Start point // - x2, y2: End point // - style: Line style. Array like for SetLineStyle function Line($x1, $y1, $x2, $y2, $style = null) { if ($style) $this->SetLineStyle($style); parent::Line($x1, $y1, $x2, $y2); } // Draws a rectangle // Parameters: // - x, y: Top left corner // - w, h: Width and height // - style: Style of rectangle (draw and/or fill: D, F, DF, FD) // - border_style: Border style of rectangle. Array with some of this index // . all: Line style of all borders. Array like for SetLineStyle // . L: Line style of left border. null (no border) or array like for SetLineStyle // . T: Line style of top border. null (no border) or array like for SetLineStyle // . R: Line style of right border. null (no border) or array like for SetLineStyle // . B: Line style of bottom border. null (no border) or array like for SetLineStyle // - fill_color: Fill color. Array with components (red, green, blue) function Rect($x, $y, $w, $h, $style = '', $border_style = null, $fill_color = null) { if (!(false === strpos($style, 'F')) && $fill_color) { list($r, $g, $b) = $fill_color; $this->SetFillColor($r, $g, $b); } switch ($style) { case 'F': $border_style = null; parent::Rect($x, $y, $w, $h, $style); break; case 'DF': case 'FD': if (!$border_style || isset($border_style['all'])) { if (isset($border_style['all'])) { $this->SetLineStyle($border_style['all']); $border_style = null; } } else $style = 'F'; parent::Rect($x, $y, $w, $h, $style); break; default: if (!$border_style || isset($border_style['all'])) { if (isset($border_style['all']) && $border_style['all']) { $this->SetLineStyle($border_style['all']); $border_style = null; } parent::Rect($x, $y, $w, $h, $style); } break; } if ($border_style) { if (isset($border_style['L']) && $border_style['L']) $this->Line($x, $y, $x, $y + $h, $border_style['L']); if (isset($border_style['T']) && $border_style['T']) $this->Line($x, $y, $x + $w, $y, $border_style['T']); if (isset($border_style['R']) && $border_style['R']) $this->Line($x + $w, $y, $x + $w, $y + $h, $border_style['R']); if (isset($border_style['B']) && $border_style['B']) $this->Line($x, $y + $h, $x + $w, $y + $h, $border_style['B']); } } // Draws a Bézier curve (the Bézier curve is tangent to the line between the control points at either end of the curve) // Parameters: // - x0, y0: Start point // - x1, y1: Control point 1 // - x2, y2: Control point 2 // - x3, y3: End point // - style: Style of rectangule (draw and/or fill: D, F, DF, FD) // - line_style: Line style for curve. Array like for SetLineStyle // - fill_color: Fill color. Array with components (red, green, blue) function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style = '', $line_style = null, $fill_color = null) { if (!(false === strpos($style, 'F')) && $fill_color) { list($r, $g, $b) = $fill_color; $this->SetFillColor($r, $g, $b); } switch ($style) { case 'F': $op = 'f'; $line_style = null; break; case 'FD': case 'DF': $op = 'B'; break; default: $op = 'S'; break; } if ($line_style) $this->SetLineStyle($line_style); $this->_Point($x0, $y0); $this->_Curve($x1, $y1, $x2, $y2, $x3, $y3); $this->_out($op); } // Draws an ellipse // Parameters: // - x0, y0: Center point // - rx, ry: Horizontal and vertical radius (if ry = 0, draws a circle) // - angle: Orientation angle (anti-clockwise) // - astart: Start angle // - afinish: Finish angle // - style: Style of ellipse (draw and/or fill: D, F, DF, FD, C (D + close)) // - line_style: Line style for ellipse. Array like for SetLineStyle // - fill_color: Fill color. Array with components (red, green, blue) // - nSeg: Ellipse is made up of nSeg Bézier curves function Ellipse($x0, $y0, $rx, $ry = 0, $angle = 0, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) { if ($rx) { if (!(false === strpos($style, 'F')) && $fill_color) { list($r, $g, $b) = $fill_color; $this->SetFillColor($r, $g, $b); } switch ($style) { case 'F': $op = 'f'; $line_style = null; break; case 'FD': case 'DF': $op = 'B'; break; case 'C': $op = 's'; // small 's' means closing the path as well break; default: $op = 'S'; break; } if ($line_style) $this->SetLineStyle($line_style); if (!$ry) $ry = $rx; $rx *= $this->k; $ry *= $this->k; if ($nSeg < 2) $nSeg = 2; $astart = deg2rad((float) $astart); $afinish = deg2rad((float) $afinish); $totalAngle = $afinish - $astart; $dt = $totalAngle/$nSeg; $dtm = $dt/3; $x0 *= $this->k; $y0 = ($this->h - $y0) * $this->k; if ($angle != 0) { $a = -deg2rad((float) $angle); $this->_out(sprintf('q %.2f %.2f %.2f %.2f %.2f %.2f cm', cos($a), -1 * sin($a), sin($a), cos($a), $x0, $y0)); $x0 = 0; $y0 = 0; } $t1 = $astart; $a0 = $x0 + ($rx * cos($t1)); $b0 = $y0 + ($ry * sin($t1)); $c0 = -$rx * sin($t1); $d0 = $ry * cos($t1); $this->_Point($a0 / $this->k, $this->h - ($b0 / $this->k)); for ($i = 1; $i <= $nSeg; $i++) { // Draw this bit of the total curve $t1 = ($i * $dt) + $astart; $a1 = $x0 + ($rx * cos($t1)); $b1 = $y0 + ($ry * sin($t1)); $c1 = -$rx * sin($t1); $d1 = $ry * cos($t1); $this->_Curve(($a0 + ($c0 * $dtm)) / $this->k, $this->h - (($b0 + ($d0 * $dtm)) / $this->k), ($a1 - ($c1 * $dtm)) / $this->k, $this->h - (($b1 - ($d1 * $dtm)) / $this->k), $a1 / $this->k, $this->h - ($b1 / $this->k)); $a0 = $a1; $b0 = $b1; $c0 = $c1; $d0 = $d1; } $this->_out($op); if ($angle !=0) $this->_out('Q'); } } // Draws a circle // Parameters: // - x0, y0: Center point // - r: Radius // - astart: Start angle // - afinish: Finish angle // - style: Style of circle (draw and/or fill) (D, F, DF, FD, C (D + close)) // - line_style: Line style for circle. Array like for SetLineStyle // - fill_color: Fill color. Array with components (red, green, blue) // - nSeg: Ellipse is made up of nSeg Bézier curves function Circle($x0, $y0, $r, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) { $this->Ellipse($x0, $y0, $r, 0, 0, $astart, $afinish, $style, $line_style, $fill_color, $nSeg); } // Draws a polygon // Parameters: // - p: Points. Array with values x0, y0, x1, y1,..., x(np-1), y(np - 1) // - style: St