You are here

function pChart::drawFilledRectangle in Visitors 7.0

Same name and namespace in other branches
  1. 8 pchart/pChart.inc \pChart::drawFilledRectangle()
5 calls to pChart::drawFilledRectangle()
pChart::drawBarGraph in pchart/pChart.inc
pChart::drawGraphArea in pchart/pChart.inc
pChart::drawPieLegend in pchart/pChart.inc
pChart::drawStackedBarGraph in pchart/pChart.inc
pChart::setLabel in pchart/pChart.inc

File

pchart/pChart.inc, line 2138

Class

pChart

Code

function drawFilledRectangle($X1, $Y1, $X2, $Y2, $R, $G, $B, $DrawBorder = TRUE, $Alpha = 100) {
  if ($R < 0) {
    $R = 0;
  }
  if ($R > 255) {
    $R = 255;
  }
  if ($G < 0) {
    $G = 0;
  }
  if ($G > 255) {
    $G = 255;
  }
  if ($B < 0) {
    $B = 0;
  }
  if ($B > 255) {
    $B = 255;
  }
  if ($Alpha == 100) {
    $C_Rectangle = imagecolorallocate($this->Picture, $R, $G, $B);
    imagefilledrectangle($this->Picture, $X1, $Y1, $X2, $Y2, $C_Rectangle);
  }
  else {
    $LayerWidth = abs($X2 - $X1) + 2;
    $LayerHeight = abs($Y2 - $Y1) + 2;
    $this->Layers[0] = imagecreatetruecolor($LayerWidth, $LayerHeight);
    $C_White = imagecolorallocate($this->Layers[0], 255, 255, 255);
    imagefilledrectangle($this->Layers[0], 0, 0, $LayerWidth, $LayerHeight, $C_White);
    imagecolortransparent($this->Layers[0], $C_White);
    $C_Rectangle = imagecolorallocate($this->Layers[0], $R, $G, $B);
    imagefilledrectangle($this->Layers[0], 1, 1, $LayerWidth - 1, $LayerHeight - 1, $C_Rectangle);
    imagecopymerge($this->Picture, $this->Layers[0], min($X1, $X2) - 1, min($Y1, $Y2) - 1, 0, 0, $LayerWidth, $LayerHeight, $Alpha);
    imagedestroy($this->Layers[0]);
  }
  if ($DrawBorder) {
    $this
      ->drawRectangle($X1, $Y1, $X2, $Y2, $R, $G, $B);
  }
}