You are here

function pSurface::drawContour in Visitors 7.2

Same name and namespace in other branches
  1. 7 pChart/class/pSurface.class.php \pSurface::drawContour()

File

pChart/class/pSurface.class.php, line 150

Class

pSurface

Code

function drawContour($Threshold, $Format = "") {
  $R = isset($Format["R"]) ? $Format["R"] : 0;
  $G = isset($Format["G"]) ? $Format["G"] : 0;
  $B = isset($Format["B"]) ? $Format["B"] : 0;
  $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
  $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 3;
  $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 0;
  $X0 = $this->pChartObject->GraphAreaX1;
  $Y0 = $this->pChartObject->GraphAreaY1;
  $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX + 1);
  $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY + 1);
  $Color = array(
    "R" => $R,
    "G" => $G,
    "B" => $B,
    "Alpha" => $Alpha,
    "Ticks" => $Ticks,
  );
  for ($X = 0; $X <= $this->GridSizeX; $X++) {
    for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
      $Value = $this->Points[$X][$Y];
      if ($Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) {
        $X1 = floor($X0 + $X * $XSize) + $Padding;
        $Y1 = floor($Y0 + $Y * $YSize) + $Padding;
        $X2 = floor($X0 + $X * $XSize + $XSize);
        $Y2 = floor($Y0 + $Y * $YSize + $YSize);
        if ($X > 0 && $this->Points[$X - 1][$Y] != UNKNOWN && $this->Points[$X - 1][$Y] != IGNORED && $this->Points[$X - 1][$Y] < $Threshold) {
          $this->pChartObject
            ->drawLine($X1, $Y1, $X1, $Y2, $Color);
        }
        if ($Y > 0 && $this->Points[$X][$Y - 1] != UNKNOWN && $this->Points[$X][$Y - 1] != IGNORED && $this->Points[$X][$Y - 1] < $Threshold) {
          $this->pChartObject
            ->drawLine($X1, $Y1, $X2, $Y1, $Color);
        }
        if ($X < $this->GridSizeX && $this->Points[$X + 1][$Y] != UNKNOWN && $this->Points[$X + 1][$Y] != IGNORED && $this->Points[$X + 1][$Y] < $Threshold) {
          $this->pChartObject
            ->drawLine($X2, $Y1, $X2, $Y2, $Color);
        }
        if ($Y < $this->GridSizeY && $this->Points[$X][$Y + 1] != UNKNOWN && $this->Points[$X][$Y + 1] != IGNORED && $this->Points[$X][$Y + 1] < $Threshold) {
          $this->pChartObject
            ->drawLine($X1, $Y2, $X2, $Y2, $Color);
        }
      }
    }
  }
}