You are here

function pChart::drawFilledRoundedRectangle in Visitors 7.0

Same name and namespace in other branches
  1. 8 pchart/pChart.inc \pChart::drawFilledRoundedRectangle()
4 calls to pChart::drawFilledRoundedRectangle()
pChart::drawLegend in pchart/pChart.inc
pChart::drawPieLegend in pchart/pChart.inc
pChart::drawRadarAxis in pchart/pChart.inc
pChart::printErrors in pchart/pChart.inc

File

pchart/pChart.inc, line 2209

Class

pChart

Code

function drawFilledRoundedRectangle($X1, $Y1, $X2, $Y2, $Radius, $R, $G, $B) {
  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;
  }
  $C_Rectangle = imagecolorallocate($this->Picture, $R, $G, $B);
  $Step = 90 / (3.1418 * $Radius / 2);
  for ($i = 0; $i <= 90; $i = $i + $Step) {
    $Xi1 = cos(($i + 180) * 3.1418 / 180) * $Radius + $X1 + $Radius;
    $Yi1 = sin(($i + 180) * 3.1418 / 180) * $Radius + $Y1 + $Radius;
    $Xi2 = cos(($i - 90) * 3.1418 / 180) * $Radius + $X2 - $Radius;
    $Yi2 = sin(($i - 90) * 3.1418 / 180) * $Radius + $Y1 + $Radius;
    $Xi3 = cos($i * 3.1418 / 180) * $Radius + $X2 - $Radius;
    $Yi3 = sin($i * 3.1418 / 180) * $Radius + $Y2 - $Radius;
    $Xi4 = cos(($i + 90) * 3.1418 / 180) * $Radius + $X1 + $Radius;
    $Yi4 = sin(($i + 90) * 3.1418 / 180) * $Radius + $Y2 - $Radius;
    imageline($this->Picture, $Xi1, $Yi1, $X1 + $Radius, $Yi1, $C_Rectangle);
    imageline($this->Picture, $X2 - $Radius, $Yi2, $Xi2, $Yi2, $C_Rectangle);
    imageline($this->Picture, $X2 - $Radius, $Yi3, $Xi3, $Yi3, $C_Rectangle);
    imageline($this->Picture, $Xi4, $Yi4, $X1 + $Radius, $Yi4, $C_Rectangle);
    $this
      ->drawAntialiasPixel($Xi1, $Yi1, $R, $G, $B);
    $this
      ->drawAntialiasPixel($Xi2, $Yi2, $R, $G, $B);
    $this
      ->drawAntialiasPixel($Xi3, $Yi3, $R, $G, $B);
    $this
      ->drawAntialiasPixel($Xi4, $Yi4, $R, $G, $B);
  }
  imagefilledrectangle($this->Picture, $X1, $Y1 + $Radius, $X2, $Y2 - $Radius, $C_Rectangle);
  imagefilledrectangle($this->Picture, $X1 + $Radius, $Y1, $X2 - $Radius, $Y2, $C_Rectangle);
  $X1 = $X1 - 0.2;
  $Y1 = $Y1 - 0.2;
  $X2 = $X2 + 0.2;
  $Y2 = $Y2 + 0.2;
  $this
    ->drawLine($X1 + $Radius, $Y1, $X2 - $Radius, $Y1, $R, $G, $B);
  $this
    ->drawLine($X2, $Y1 + $Radius, $X2, $Y2 - $Radius, $R, $G, $B);
  $this
    ->drawLine($X2 - $Radius, $Y2, $X1 + $Radius, $Y2, $R, $G, $B);
  $this
    ->drawLine($X1, $Y2 - $Radius, $X1, $Y1 + $Radius, $R, $G, $B);
}