Wrapper taking custom units and margins into account
@see \ZendPdf\Page::drawRoundedRectangle() for documentation
505526
public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType = \ZendPdf\Page::SHAPE_DRAW_FILL_AND_STROKE)
    {
        $this->convertCoordinatesFromUserSpace($x1, $y1);
        $this->convertCoordinatesFromUserSpace($x2, $y2);
        list($y1, $y2) = array($y2, $y1);
        $this->convertToPoints($radius);
        return parent::drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType);
    }
1025299
public void drawRectangle(int x, int y, int z, int width, int height, int color, int alpha)
	{
		drawRectangle(x, y, z, width, height, color, alpha, true);
	}
375390
public function draw2DPie($X, $Y, array $Format = [])
    {
        $Radius = isset($Format["Radius"]) ? $Format["Radius"] : 60;
        $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0;
        $DataGapAngle = isset($Format["DataGapAngle"]) ? $Format["DataGapAngle"] : 0;
        $DataGapRadius = isset($Format["DataGapRadius"]) ? $Format["DataGapRadius"] : 0;
        $SecondPass = isset($Format["SecondPass"]) ? $Format["SecondPass"] : true;
        $Border = isset($Format["Border"]) ? $Format["Border"] : false;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 255;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 255;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 255;
        $Shadow = isset($Format["Shadow"]) ? $Format["Shadow"] : false;
        $DrawLabels = isset($Format["DrawLabels"]) ? $Format["DrawLabels"] : false;
        $LabelStacked = isset($Format["LabelStacked"]) ? $Format["LabelStacked"] : false;
        $LabelColor = isset($Format["LabelColor"]) ? $Format["LabelColor"] : PIE_LABEL_COLOR_MANUAL;
        $LabelR = isset($Format["LabelR"]) ? $Format["LabelR"] : 0;
        $LabelG = isset($Format["LabelG"]) ? $Format["LabelG"] : 0;
        $LabelB = isset($Format["LabelB"]) ? $Format["LabelB"] : 0;
        $LabelAlpha = isset($Format["LabelAlpha"]) ? $Format["LabelAlpha"] : 100;
        $WriteValues = isset($Format["WriteValues"]) ? $Format["WriteValues"] : null;
        $ValuePosition = isset($Format["ValuePosition"]) ? $Format["ValuePosition"] : PIE_VALUE_OUTSIDE;
        $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 15;
        $ValueSuffix = isset($Format["ValueSuffix"]) ? $Format["ValueSuffix"] : "";
        $ValueR = isset($Format["ValueR"]) ? $Format["ValueR"] : 255;
        $ValueG = isset($Format["ValueG"]) ? $Format["ValueG"] : 255;
        $ValueB = isset($Format["ValueB"]) ? $Format["ValueB"] : 255;
        $ValueAlpha = isset($Format["ValueAlpha"]) ? $Format["ValueAlpha"] : 100;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;

        $Data = $this->pDataObject->getData();
        $Palette = $this->pDataObject->getPalette();

        /* Do we have an abscissa serie defined? */
        if ($Data["Abscissa"] == "") {
            return PIE_NO_ABSCISSA;
        }

        /* Try to find the data serie */
        $DataSerie = null;
        foreach (array_keys($Data["Series"]) as $SerieName) {
            if ($SerieName != $Data["Abscissa"]) {
                $DataSerie = $SerieName;
            }
        }

        /* Do we have data to compute? */
        if (!$DataSerie) {
            return PIE_NO_DATASERIE;
        }

        /* Remove unused data */
        list($Data, $Palette) = $this->clean0Values($Data, $Palette, $DataSerie, $Data["Abscissa"]);

        /* Compute the pie sum */
        $SerieSum = $this->pDataObject->getSum($DataSerie);

        /* Do we have data to draw? */
        if ($SerieSum == 0) {
            return PIE_SUMISNULL;
        }

        /* Dump the real number of data to draw */
        $Values = [];
        foreach ($Data["Series"][$DataSerie]["Data"] as $Key => $Value) {
            if ($Value != 0) {
                $Values[] = $Value;
            }
        }

        /* Compute the wasted angular space between series */
        if (count($Values) == 1) {
            $WastedAngular = 0;
        } else {
            $WastedAngular = count($Values) * $DataGapAngle;
        }

        /* Compute the scale */
        $ScaleFactor = (360 - $WastedAngular) / $SerieSum;

        $RestoreShadow = $this->pChartObject->Shadow;
        if ($this->pChartObject->Shadow) {
            $this->pChartObject->Shadow = false;

            $ShadowFormat = $Format;
            $ShadowFormat["Shadow"] = true;
            $this->draw2DPie(
                $X + $this->pChartObject->ShadowX,
                $Y + $this->pChartObject->ShadowY,
                $ShadowFormat
            );
        }

        /* Draw the polygon pie elements */
        $Step = 360 / (2 * PI * $Radius);
        $Offset = 0;
        $ID = 0;
        foreach ($Values as $Key => $Value) {
            if ($Shadow) {
                $Settings = [
                    "R" => $this->pChartObject->ShadowR,
                    "G" => $this->pChartObject->ShadowG,
                    "B" => $this->pChartObject->ShadowB,
                    "Alpha" => $this->pChartObject->Shadowa
                ];
            } else {
                if (!isset($Palette[$ID]["R"])) {
                    $Color = $this->pChartObject->getRandomColor();
                    $Palette[$ID] = $Color;
                    $this->pDataObject->savePalette($ID, $Color);
                }
                $Settings = [
                    "R" => $Palette[$ID]["R"],
                    "G" => $Palette[$ID]["G"],
                    "B" => $Palette[$ID]["B"],
                    "Alpha" => $Palette[$ID]["Alpha"]
                ];
            }

            if (!$SecondPass && !$Shadow) {
                if (!$Border) {
                    $Settings["Surrounding"] = 10;
                } else {
                    $Settings["BorderR"] = $BorderR;
                    $Settings["BorderG"] = $BorderG;
                    $Settings["BorderB"] = $BorderB;
                }
            }

            $EndAngle = $Offset + ($Value * $ScaleFactor);
            if ($EndAngle > 360) {
                $EndAngle = 360;
            }

            $Angle = ($EndAngle - $Offset) / 2 + $Offset;
            if ($DataGapAngle == 0) {
                $X0 = $X;
                $Y0 = $Y;
            } else {
                $X0 = cos(($Angle - 90) * PI / 180) * $DataGapRadius + $X;
                $Y0 = sin(($Angle - 90) * PI / 180) * $DataGapRadius + $Y;
            }

            $Plots = [$X0, $Y0];

            for ($i = $Offset; $i <= $EndAngle; $i = $i + $Step) {
                $Xc = cos(($i - 90) * PI / 180) * $Radius + $X;
                $Yc = sin(($i - 90) * PI / 180) * $Radius + $Y;

                if ($SecondPass && ($i < 90)) {
                    $Yc++;
                }
                if ($SecondPass && ($i > 180 && $i < 270)) {
                    $Xc++;
                }
                if ($SecondPass && ($i >= 270)) {
                    $Xc++;
                    $Yc++;
                }

                $Plots[] = $Xc;
                $Plots[] = $Yc;
            }

            $this->pChartObject->drawPolygon($Plots, $Settings);
            if ($RecordImageMap && !$Shadow) {
                $this->pChartObject->addToImageMap(
                    "POLY",
                    $this->arraySerialize($Plots),
                    $this->pChartObject->toHTMLColor(
                        $Palette[$ID]["R"],
                        $Palette[$ID]["G"],
                        $Palette[$ID]["B"]
                    ),
                    $Data["Series"][$Data["Abscissa"]]["Data"][$Key],
                    $Value
                );
            }

            if ($DrawLabels && !$Shadow && !$SecondPass) {
                if ($LabelColor == PIE_LABEL_COLOR_AUTO) {
                    $Settings = [
                        "FillR" => $Palette[$ID]["R"],
                        "FillG" => $Palette[$ID]["G"],
                        "FillB" => $Palette[$ID]["B"],
                        "Alpha" => $Palette[$ID]["Alpha"]
                    ];
                } else {
                    $Settings = [
                        "FillR" => $LabelR,
                        "FillG" => $LabelG,
                        "FillB" => $LabelB,
                        "Alpha" => $LabelAlpha
                    ];
                }

                $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                $Yc = sin(($Angle - 90) * PI / 180) * $Radius + $Y;

                $Label = $Data["Series"][$Data["Abscissa"]]["Data"][$Key];

                if ($LabelStacked) {
                    $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, true, $X, $Y, $Radius);
                } else {
                    $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, false);
                }
            }

            $Offset = $i + $DataGapAngle;
            $ID++;
        }

        /* Second pass to smooth the angles */
        if ($SecondPass) {
            $Step = 360 / (2 * PI * $Radius);
            $Offset = 0;
            $ID = 0;
            foreach ($Values as $Key => $Value) {
                $FirstPoint = true;
                if ($Shadow) {
                    $Settings = [
                        "R" => $this->pChartObject->ShadowR,
                        "G" => $this->pChartObject->ShadowG,
                        "B" => $this->pChartObject->ShadowB,
                        "Alpha" => $this->pChartObject->Shadowa
                    ];
                } else {
                    if ($Border) {
                        $Settings = ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB];
                    } else {
                        $Settings = [
                            "R" => $Palette[$ID]["R"],
                            "G" => $Palette[$ID]["G"],
                            "B" => $Palette[$ID]["B"],
                            "Alpha" => $Palette[$ID]["Alpha"]
                        ];
                    }
                }

                $EndAngle = $Offset + ($Value * $ScaleFactor);
                if ($EndAngle > 360) {
                    $EndAngle = 360;
                }

                if ($DataGapAngle == 0) {
                    $X0 = $X;
                    $Y0 = $Y;
                } else {
                    $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                    $X0 = cos(($Angle - 90) * PI / 180) * $DataGapRadius + $X;
                    $Y0 = sin(($Angle - 90) * PI / 180) * $DataGapRadius + $Y;
                }
                $Plots[] = $X0;
                $Plots[] = $Y0;

                for ($i = $Offset; $i <= $EndAngle; $i = $i + $Step) {
                    $Xc = cos(($i - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin(($i - 90) * PI / 180) * $Radius + $Y;

                    if ($FirstPoint) {
                        $this->pChartObject->drawLine($Xc, $Yc, $X0, $Y0, $Settings);
                        $FirstPoint = false;
                    }

                    $this->pChartObject->drawAntialiasPixel($Xc, $Yc, $Settings);
                }
                $this->pChartObject->drawLine($Xc, $Yc, $X0, $Y0, $Settings);

                if ($DrawLabels && !$Shadow) {
                    if ($LabelColor == PIE_LABEL_COLOR_AUTO) {
                        $Settings = [
                            "FillR" => $Palette[$ID]["R"],
                            "FillG" => $Palette[$ID]["G"],
                            "FillB" => $Palette[$ID]["B"],
                            "Alpha" => $Palette[$ID]["Alpha"]
                        ];
                    } else {
                        $Settings = [
                            "FillR" => $LabelR,
                            "FillG" => $LabelG,
                            "FillB" => $LabelB,
                            "Alpha" => $LabelAlpha
                        ];
                    }

                    $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                    $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * $Radius + $Y;

                    $Label = $Data["Series"][$Data["Abscissa"]]["Data"][$Key];

                    if ($LabelStacked) {
                        $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, true, $X, $Y, $Radius);
                    } else {
                        $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, false);
                    }
                }

                $Offset = $i + $DataGapAngle;
                $ID++;
            }
        }

        if ($WriteValues != null && !$Shadow) {
            $Step = 360 / (2 * PI * $Radius);
            $Offset = 0;
            $ID = count($Values) - 1;
            $Settings = [
                "Align" => TEXT_ALIGN_MIDDLEMIDDLE,
                "R" => $ValueR,
                "G" => $ValueG,
                "B" => $ValueB,
                "Alpha" => $ValueAlpha
            ];
            foreach ($Values as $Key => $Value) {
                $EndAngle = ($Value * $ScaleFactor) + $Offset;
                if ((int) $EndAngle > 360) {
                    $EndAngle = 0;
                }
                $Angle = ($EndAngle - $Offset) / 2 + $Offset;

                if ($ValuePosition == PIE_VALUE_OUTSIDE) {
                    $Xc = cos(($Angle - 90) * PI / 180) * ($Radius + $ValuePadding) + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * ($Radius + $ValuePadding) + $Y;
                } else {
                    $Xc = cos(($Angle - 90) * PI / 180) * ($Radius) / 2 + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * ($Radius) / 2 + $Y;
                }

                if ($WriteValues == PIE_VALUE_PERCENTAGE) {
                    $Display = round((100 / $SerieSum) * $Value, $Precision) . "%";
                } elseif ($WriteValues == PIE_VALUE_NATURAL) {
                    $Display = $Value . $ValueSuffix;
                }
                $this->pChartObject->drawText($Xc, $Yc, $Display, $Settings);

                $Offset = $EndAngle + $DataGapAngle;
                $ID--;
            }
        }

        if ($DrawLabels && $LabelStacked) {
            $this->writeShiftedLabels();
        }

        $this->pChartObject->Shadow = $RestoreShadow;

        return PIE_RENDERED;
    }
453957
public function drawRoundedFilledRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : 0;
        $G = isset($Format["G"]) ? $Format["G"] : 0;
        $B = isset($Format["B"]) ? $Format["B"] : 0;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null;

        /* Temporary fix for AA issue */
        $Y1 = floor($Y1);
        $Y2 = floor($Y2);
        $X1 = floor($X1);
        $X2 = floor($X2);

        if ($Surrounding != null) {
            $BorderR = $R + $Surrounding;
            $BorderG = $G + $Surrounding;
            $BorderB = $B + $Surrounding;
        }
        if ($BorderR == -1) {
            $BorderR = $R;
            $BorderG = $G;
            $BorderB = $B;
        }

        list($X1, $Y1, $X2, $Y2) = $this->fixBoxCoordinates($X1, $Y1, $X2, $Y2);

        if ($X2 - $X1 < $Radius * 2) {
            $Radius = floor((($X2 - $X1)) / 4);
        }
        if ($Y2 - $Y1 < $Radius * 2) {
            $Radius = floor((($Y2 - $Y1)) / 4);
        }

        $RestoreShadow = $this->Shadow;
        if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
            $this->Shadow = false;
            $this->drawRoundedFilledRectangle(
                $X1 + $this->ShadowX,
                $Y1 + $this->ShadowY,
                $X2 + $this->ShadowX,
                $Y2 + $this->ShadowY,
                $Radius,
                [
                    "R" => $this->ShadowR,
                    "G" => $this->ShadowG,
                    "B" => $this->ShadowB,
                    "Alpha" => $this->Shadowa
                ]
            );
        }

        $Color = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "NoBorder" => true];

        if ($Radius <= 0) {
            $this->drawFilledRectangle($X1, $Y1, $X2, $Y2, $Color);
            return 0;
        }

        $YTop = $Y1 + $Radius;
        $YBottom = $Y2 - $Radius;

        $Step = 360 / (2 * PI * $Radius);
        $Positions = [];
        $Radius--;
        $MinY = null;
        $MaxY = null;
        for ($i = 0; $i <= 90; $i = $i + $Step) {
            $Xp1 = cos(($i + 180) * PI / 180) * $Radius + $X1 + $Radius;
            $Xp2 = cos(((90 - $i) + 270) * PI / 180) * $Radius + $X2 - $Radius;
            $Yp = floor(sin(($i + 180) * PI / 180) * $Radius + $YTop);
            if (null === $MinY || $Yp > $MinY) {
                $MinY = $Yp;
            }

            if ($Xp1 <= floor($X1)) {
                $Xp1++;
            }
            if ($Xp2 >= floor($X2)) {
                $Xp2--;
            }
            $Xp1++;

            if (!isset($Positions[$Yp])) {
                $Positions[$Yp]["X1"] = $Xp1;
                $Positions[$Yp]["X2"] = $Xp2;
            } else {
                $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"] + $Xp1) / 2;
                $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"] + $Xp2) / 2;
            }

            $Xp1 = cos(($i + 90) * PI / 180) * $Radius + $X1 + $Radius;
            $Xp2 = cos((90 - $i) * PI / 180) * $Radius + $X2 - $Radius;
            $Yp = floor(sin(($i + 90) * PI / 180) * $Radius + $YBottom);
            if (null === $MaxY || $Yp < $MaxY) {
                $MaxY = $Yp;
            }

            if ($Xp1 <= floor($X1)) {
                $Xp1++;
            }
            if ($Xp2 >= floor($X2)) {
                $Xp2--;
            }
            $Xp1++;

            if (!isset($Positions[$Yp])) {
                $Positions[$Yp]["X1"] = $Xp1;
                $Positions[$Yp]["X2"] = $Xp2;
            } else {
                $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"] + $Xp1) / 2;
                $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"] + $Xp2) / 2;
            }
        }

        $ManualColor = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
        foreach ($Positions as $Yp => $Bounds) {
            $X1 = $Bounds["X1"];
            $X1Dec = $this->getFirstDecimal($X1);
            if ($X1Dec != 0) {
                $X1 = floor($X1) + 1;
            }
            $X2 = $Bounds["X2"];
            $X2Dec = $this->getFirstDecimal($X2);
            if ($X2Dec != 0) {
                $X2 = floor($X2) - 1;
            }
            imageline($this->Picture, $X1, $Yp, $X2, $Yp, $ManualColor);
        }
        $this->drawFilledRectangle($X1, $MinY + 1, floor($X2), $MaxY - 1, $Color);

        $Radius++;
        $this->drawRoundedRectangle(
            $X1,
            $Y1,
            $X2 + 1,
            $Y2 - 1,
            $Radius,
            ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
        );

        $this->Shadow = $RestoreShadow;
    }
1284113
private function drawDivider(string $prefix = 'sep_'): string
    {
        $divider = '';
        foreach ($this->columnsWidths as $width) {
            // Column width position for the xSep + left and rigth padding
            $times = $width + $this->options['cells_padding'][1] + $this->options['cells_padding'][3];
            $divider .= $this->options[$prefix . 'x'] . $this->repeatChar($this->options[$prefix . 'h'], $times);
        }

        return $divider . $this->options[$prefix . 'x'] . PHP_EOL;
    }
15524
public function drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null)
    {
        // Don't convert units and call parent::drawCircle(), since it calls drawEllipse which will convert units twice!
        return $this->drawEllipse($x - $radius, $y - $radius, $x + $radius, $y + $radius, $param4, $param5, $param6);
    }
1328867
function DrawGraph() {

    if (($this->img) == "") {
      $this->DrawError('No Image Defined: DrawGraph');
            //$this->PHPlot();
        }

    if (! is_array($this->data_values)) {
      $this->DrawBackground();
      $this->DrawError("No array of data in \$data_values");
    } else {
      if (!$this->data_color) {
        $this->SetDataColors(array('blue','green','yellow','red','orange','blue'),array('black'));
      }

      $this->FindDataLimits();  //Get maxima and minima for scaling

      $this->SetXLabelHeight();		//Get data for bottom margin

      $this->SetYLabelWidth();		//Get data for left margin

      if (!$this->plot_area_width) {
        $this->SetPlotAreaPixels('','','','');		//Set Margins
      }

      if (!$this->plot_max_y) {  //If not set by user call SetPlotAreaWorld,
        $this->SetPlotAreaWorld('','','','');
      }

      if ($this->data_type == "text-data") {
        $this->SetEqualXCoord();
      }

      $this->SetPointSize($this->point_size);

      $this->DrawBackground();
      $this->DrawImageBorder();

      $this->SetTranslation();

      if ($this->draw_plot_area_background == 1) {
        $this->DrawPlotAreaBackground();
      }
//$foo = "$this->max_y, $this->min_y, $new_miny, $new_maxy, $this->x_label_height";
//ImageString($this->img, 4, 20, 20, $foo, $this->ndx_text_color);

      switch ($this->plot_type) {
        case "bars":
          $this->DrawPlotBorder();
          $this->DrawLabels();
          $this->DrawBars();
          $this->DrawXAxis();
          break;
        case "thinbarline":
          $this->DrawPlotBorder();
          $this->DrawLabels();
          $this->DrawThinBarLines();
          break;
        case "lines":
          $this->DrawPlotBorder();
          $this->DrawLabels();
          if ( $this->data_type == "text-data") {
            $this->DrawLines();
          } elseif ( $this->data_type == "data-data-error") {
            $this->DrawLinesError();
          } else {
            $this->DrawLines();
          }
          break;
        case "area":
          $this->DrawPlotBorder();
          $this->DrawLabels();
          if ( $this->data_type == "text-data") {
            $this->DrawAreaSeries();
          } else {
            $this->DrawArea();
          }
          break;
        case "linepoints":
          $this->DrawPlotBorder();
          $this->DrawLabels();
          if ( $this->data_type == "text-data") {
            $this->DrawLines();
            $this->DrawDots();
          } elseif ( $this->data_type == "data-data-error") {
            $this->DrawLinesError();
            $this->DrawDotsError();
          } else {
            $this->DrawLines();
            $this->DrawDots();
          }
          break;
        case "points";
          $this->DrawPlotBorder();
          $this->DrawLabels();
          if ( $this->data_type == "text-data") {
            $this->DrawDots();
          } elseif ( $this->data_type == "data-data-error") {
            $this->DrawDotsError();
          } else {
            $this->DrawDots();
          }
          break;
        case "pie":
          $this->DrawPieChart();
          $this->DrawLabels();
          break;
        default:
          $this->DrawPlotBorder();
          $this->DrawLabels();
          $this->DrawBars();
          break;
      }

      if ($this->legend) {
        $this->DrawLegend($this->legend_x_pos,$this->legend_y_pos,'');
      }

    }
    if ($this->print_image == 1) {
      $this->PrintImage();
    }
  }
530526
private function drawRectangle(
    CanvasInterface $canvas, StyleInterface $style = null, $filled = false)
    {

        $x = $this->getStart()->getX();
        $y = $this->getStart()->getY();
        $color = (!is_null($style)) ?
                $style->apply($canvas, $this)->getValue() :
                $this->getColor()->getValue();

        $result = false;

        if (true === $filled) {
            $result = @imagefilledrectangle(
                            $canvas->getHandler()
                            , $x
                            , $y
                            , $this->getDimension()->getWidth() + $x
                            , $this->getDimension()->getHeight() + $y
                            , $color
            );
        } else {
            $result = @imagerectangle(
                            $canvas->getHandler()
                            , $x
                            , $y
                            , $this->getDimension()->getWidth() + $x
                            , $this->getDimension()->getHeight() + $y
                            , $color
            );
        }

        if (false == $result) {
            throw new DrawableException(sprintf(
                    'Faild To Draw The Rectangle "%s"', (string) $this
            ));
        }
    }
689810
protected function drawBarCode($baseline = 0.8, $height = 13)
    {
        $data = $this->data['barcode'];
        $wide = $baseline;
        $narrow = $baseline / 3;
        $map = [
            '00110',
            '10001',
            '01001',
            '11000',
            '00101',
            '10100',
            '01100',
            '00011',
            '10010',
            '01010'
        ];

        // If odd $data
        if ((strlen($data) % 2) != 0) {
            $data = '0' . $data;
        }
        // Generate bits to be draw
        $code = '0000'; // Leading value
        for ($i = 0, $l = strlen($data); $i < $l; $i += 2) {
            $code .= implode('', Utils\Utils::arrayInterpolate(
                $map[$data[$i]],
                $map[$data[$i + 1]]
            ));
        }
        $code .= '100'; // Trailing value

        // Draw
        $this->SetFillColor(0);
        $x = $this->GetX();
        $y = $this->GetY();
        $draw = true;
        foreach (str_split($code, 1) as $bit) {
            $width = ($bit == '0' ? $narrow : $wide);
            if ($draw) {
                $this->Rect($x, $y, $width, $height, 'F');
            }
            $x += $width;
            $draw = !$draw;
        }
        $this->Ln($height);
    }
958448
void drawDivider(Canvas canvas, Rect bounds, int childIndex) {
        final Drawable divider = getDivider();
        divider.setBounds(bounds);
        divider.draw(canvas);
    }
596592
public void drawMapRectangle() {
		mapWidget.getVectorContext().drawRectangle(group, MAP_AREA, 
				new Bbox(0, 0, mapWidget.getWidth(), mapWidget.getHeight()), 
				// IE9 does not draw an empty shapestyle (new ShapeStyle()), but it does draw one with opacity = 0...
				new ShapeStyle("#00FF00", 0, "#00FF00", 0, 1));
//				new ShapeStyle("#00FF00", 0.1f, "#00FF00", 0.5f, 1));
	}
951362
def draw_rectangle(x, y, width, height)
      @context.drawRect(x, y, width, height)
    end
451468
public function svgRect($x, $y, $w, $h, $style)
    {
        // prepare the 4 corners
        $x1=$x;
        $x2=$x+$w;
        $x3=$x+$w;
        $x4=$x;

        $y1=$y;
        $y2=$y;
        $y3=$y+$h;
        $y4=$y+$h;

        // get the Closing operator from the PDF Style
        if($style=='F') $op='f';
        elseif($style=='FD' || $style=='DF') $op='B';
        else $op='S';

        // drawing
        $this->_Point($x1, $y1, true);
        $this->_Line($x2, $y2, true);
        $this->_Line($x3, $y3, true);
        $this->_Line($x4, $y4, true);
        $this->_Line($x1, $y1, true);
        $this->_out($op);
    }
212006
public void strokeRoundRectangle(Rectangle rect, Color color, float linewidth, float r) {
		template.saveState();
		setStroke(color, linewidth, null);
		template.roundRectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight(), r);
		template.stroke();
		template.restoreState();
	}
615602
public function drawBubbleChart($DataSeries, $WeightSeries, $Format = "")
    {
        $ForceAlpha = isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : VOID;
        $DrawBorder = isset($Format["DrawBorder"]) ? $Format["DrawBorder"] : true;
        $BorderWidth = isset($Format["BorderWidth"]) ? $Format["BorderWidth"] : 1;
        $Shape = isset($Format["Shape"]) ? $Format["Shape"] : BUBBLE_SHAPE_ROUND;
        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
        $BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 30;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;

        if (!is_array($DataSeries)) {
            $DataSeries = [$DataSeries];
        }
        if (!is_array($WeightSeries)) {
            $WeightSeries = [$WeightSeries];
        }

        $Data = $this->pDataObject->getData();
        $Palette = $this->pDataObject->getPalette();

        if (isset($Data["Series"]["BubbleFakePositiveSerie"])) {
            $this->pDataObject->setSerieDrawable("BubbleFakePositiveSerie", false);
        }
        if (isset($Data["Series"]["BubbleFakeNegativeSerie"])) {
            $this->pDataObject->setSerieDrawable("BubbleFakeNegativeSerie", false);
        }

        $this->resetSeriesColors();

        list($XMargin, $XDivs) = $this->pChartObject->scaleGetXSettings();

        foreach ($DataSeries as $Key => $SerieName) {
            $AxisID = $Data["Series"][$SerieName]["Axis"];
            $Mode = $Data["Axis"][$AxisID]["Display"];
            $Format = $Data["Axis"][$AxisID]["Format"];
            $Unit = $Data["Axis"][$AxisID]["Unit"];

            if (isset($Data["Series"][$SerieName]["Description"])) {
                $SerieDescription = $Data["Series"][$SerieName]["Description"];
            } else {
                $SerieDescription = $SerieName;
            }

            $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2) / $XDivs;

            $X = $this->pChartObject->GraphAreaX1 + $XMargin;
            $Y = $this->pChartObject->GraphAreaY1 + $XMargin;

            $Color = [
                "R" => $Palette[$Key]["R"],
                "G" => $Palette[$Key]["G"],
                "B" => $Palette[$Key]["B"],
                "Alpha" => $Palette[$Key]["Alpha"]
            ];

            if ($ForceAlpha != VOID) {
                $Color["Alpha"] = $ForceAlpha;
            }

            if ($DrawBorder) {
                if ($BorderWidth != 1) {
                    if ($Surrounding != null) {
                        $BorderR = $Palette[$Key]["R"] + $Surrounding;
                        $BorderG = $Palette[$Key]["G"] + $Surrounding;
                        $BorderB = $Palette[$Key]["B"] + $Surrounding;
                    }
                    if ($ForceAlpha != VOID) {
                        $BorderAlpha = $ForceAlpha / 2;
                    }
                    $BorderColor = [
                        "R" => $BorderR,
                        "G" => $BorderG,
                        "B" => $BorderB,
                        "Alpha" => $BorderAlpha
                    ];
                } else {
                    $Color["BorderAlpha"] = $BorderAlpha;

                    if ($Surrounding != null) {
                        $Color["BorderR"] = $Palette[$Key]["R"] + $Surrounding;
                        $Color["BorderG"] = $Palette[$Key]["G"] + $Surrounding;
                        $Color["BorderB"] = $Palette[$Key]["B"] + $Surrounding;
                    } else {
                        $Color["BorderR"] = $BorderR;
                        $Color["BorderG"] = $BorderG;
                        $Color["BorderB"] = $BorderB;
                    }
                    if ($ForceAlpha != VOID) {
                        $Color["BorderAlpha"] = $ForceAlpha / 2;
                    }
                }
            }

            foreach ($Data["Series"][$SerieName]["Data"] as $iKey => $Point) {
                $Weight = $Point + $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey];

                $PosArray = $this->pChartObject->scaleComputeY(
                    $Point,
                    ["AxisID" => $AxisID]
                );
                $WeightArray = $this->pChartObject->scaleComputeY(
                    $Weight,
                    ["AxisID" => $AxisID]
                );

                if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
                    if ($XDivs == 0) {
                        $XStep = 0;
                    } else {
                        $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2)
                            / $XDivs
                        ;
                    }
                    $Y = floor($PosArray);
                    $CircleRadius = floor(abs($PosArray - $WeightArray) / 2);

                    if ($Shape == BUBBLE_SHAPE_SQUARE) {
                        if ($RecordImageMap) {
                            $this->pChartObject->addToImageMap(
                                "RECT",
                                (
                                    floor($X - $CircleRadius)
                                    . "," . floor($Y - $CircleRadius)
                                    . "," . floor($X + $CircleRadius)
                                    . "," . floor($Y + $CircleRadius)
                                ),
                                $this->pChartObject->toHTMLColor(
                                    $Palette[$Key]["R"],
                                    $Palette[$Key]["G"],
                                    $Palette[$Key]["B"]
                                ),
                                $SerieDescription,
                                $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]
                            );
                        }

                        if ($BorderWidth != 1) {
                            $this->pChartObject->drawFilledRectangle(
                                $X - $CircleRadius - $BorderWidth,
                                $Y - $CircleRadius - $BorderWidth,
                                $X + $CircleRadius + $BorderWidth,
                                $Y + $CircleRadius + $BorderWidth,
                                $BorderColor
                            );
                            $this->pChartObject->drawFilledRectangle(
                                $X - $CircleRadius,
                                $Y - $CircleRadius,
                                $X + $CircleRadius,
                                $Y + $CircleRadius,
                                $Color
                            );
                        } else {
                            $this->pChartObject->drawFilledRectangle(
                                $X - $CircleRadius,
                                $Y - $CircleRadius,
                                $X + $CircleRadius,
                                $Y + $CircleRadius,
                                $Color
                            );
                        }
                    } elseif ($Shape == BUBBLE_SHAPE_ROUND) {
                        if ($RecordImageMap) {
                            $this->pChartObject->addToImageMap(
                                "CIRCLE",
                                floor($X) . "," . floor($Y) . "," . floor($CircleRadius),
                                $this->pChartObject->toHTMLColor(
                                    $Palette[$Key]["R"],
                                    $Palette[$Key]["G"],
                                    $Palette[$Key]["B"]
                                ),
                                $SerieDescription,
                                $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]
                            );
                        }

                        if ($BorderWidth != 1) {
                            $this->pChartObject->drawFilledCircle(
                                $X,
                                $Y,
                                $CircleRadius + $BorderWidth,
                                $BorderColor
                            );
                            $this->pChartObject->drawFilledCircle($X, $Y, $CircleRadius, $Color);
                        } else {
                            $this->pChartObject->drawFilledCircle($X, $Y, $CircleRadius, $Color);
                        }
                    }

                    $X = $X + $XStep;
                } elseif ($Data["Orientation"] == SCALE_POS_TOPBOTTOM) {
                    if ($XDivs == 0) {
                        $XStep = 0;
                    } else {
                        $XStep = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $XMargin * 2)
                            / $XDivs
                        ;
                    }
                    $X = floor($PosArray);
                    $CircleRadius = floor(abs($PosArray - $WeightArray) / 2);

                    if ($Shape == BUBBLE_SHAPE_SQUARE) {
                        if ($RecordImageMap) {
                            $this->pChartObject->addToImageMap(
                                "RECT",
                                (
                                    floor($X - $CircleRadius) . ","
                                    . floor($Y - $CircleRadius) . ","
                                    . floor($X + $CircleRadius) . ","
                                    . floor($Y + $CircleRadius)
                                ),
                                $this->pChartObject->toHTMLColor(
                                    $Palette[$Key]["R"],
                                    $Palette[$Key]["G"],
                                    $Palette[$Key]["B"]
                                ),
                                $SerieDescription,
                                $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]
                            );
                        }

                        if ($BorderWidth != 1) {
                            $this->pChartObject->drawFilledRectangle(
                                $X - $CircleRadius - $BorderWidth,
                                $Y - $CircleRadius - $BorderWidth,
                                $X + $CircleRadius + $BorderWidth,
                                $Y + $CircleRadius + $BorderWidth,
                                $BorderColor
                            );
                            $this->pChartObject->drawFilledRectangle(
                                $X - $CircleRadius,
                                $Y - $CircleRadius,
                                $X + $CircleRadius,
                                $Y + $CircleRadius,
                                $Color
                            );
                        } else {
                            $this->pChartObject->drawFilledRectangle(
                                $X - $CircleRadius,
                                $Y - $CircleRadius,
                                $X + $CircleRadius,
                                $Y + $CircleRadius,
                                $Color
                            );
                        }
                    } elseif ($Shape == BUBBLE_SHAPE_ROUND) {
                        if ($RecordImageMap) {
                            $this->pChartObject->addToImageMap(
                                "CIRCLE",
                                floor($X) . "," . floor($Y) . "," . floor($CircleRadius),
                                $this->pChartObject->toHTMLColor(
                                    $Palette[$Key]["R"],
                                    $Palette[$Key]["G"],
                                    $Palette[$Key]["B"]
                                ),
                                $SerieDescription,
                                $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]
                            );
                        }

                        if ($BorderWidth != 1) {
                            $this->pChartObject->drawFilledCircle(
                                $X,
                                $Y,
                                $CircleRadius + $BorderWidth,
                                $BorderColor
                            );
                            $this->pChartObject->drawFilledCircle($X, $Y, $CircleRadius, $Color);
                        } else {
                            $this->pChartObject->drawFilledCircle($X, $Y, $CircleRadius, $Color);
                        }
                    }

                    $Y = $Y + $XStep;
                }
            }
        }
    }
181431
protected function drawCirlce($canvas, $w, $h, $r, $g, $b, $opc, $cirle = true)
    {

        $centerX     = floor($w / 2);
        $centerY     = floor($h / 2);

        if ($cirle) {
            $w = $h = min($w, $h);
        }

        $offset = 2 * $this->getOption('o', 1);

        $xa         = ($w - $offset) / 2;
        $xb         = ($h - $offset) / 2;
        $thickness = 2.5 / min($xa, $xb);

        $color  = imagecolorallocatealpha($canvas, $r, $g, $b, $opc);
        $maxTransparency = 127;


        for ($x = 0; $x <= $xa + 1; $x++) {
            for ($y = 0; $y <= $xb + 1; $y++) {

                // implicit formula: 1 = $x*$x/($a*$a) + $y*$y/($b*$b)
                $one = $x*$x/($xa*$xa) + $y*$y/($xb*$xb);
                $bound = ($one - 1) / $thickness;

                if ($bound > 1) {
                    break;
                }
                $transparency = round(abs($bound) * $maxTransparency);
                $alpha        = $bound < -($thickness)  ? $color : $color | ($transparency << 24);

                // draw circle
                imagesetpixel($canvas, $centerX + $x, $centerY + $y, $alpha);
                imagesetpixel($canvas, $centerX - $x, $centerY + $y, $alpha);
                imagesetpixel($canvas, $centerX - $x, $centerY - $y, $alpha);
                imagesetpixel($canvas, $centerX + $x, $centerY - $y, $alpha);
            }
        }

        return $canvas;
    }
160452
function filled_rectangle($x1, $y1, $w, $h, $color) {

    $this->_set_fill_colour($color);
    
    // FIXME: ugh, need to handle styles here
    $this->_pdf->rect($x1, $y1, $w, $h, "F");
  }