You are here

function pSurface::drawSurface in Visitors 7.2

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

File

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

Class

pSurface

Code

function drawSurface($Format = "") {
  $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL;
  $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77;
  $ShadeG1 = isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205;
  $ShadeB1 = isset($Format["ShadeB1"]) ? $Format["ShadeB1"] : 21;
  $ShadeA1 = isset($Format["ShadeA1"]) ? $Format["ShadeA1"] : 40;
  $ShadeR2 = isset($Format["ShadeR2"]) ? $Format["ShadeR2"] : 227;
  $ShadeG2 = isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135;
  $ShadeB2 = isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61;
  $ShadeA2 = isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100;
  $Border = isset($Format["Border"]) ? $Format["Border"] : FALSE;
  $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
  $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
  $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
  $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1;
  $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 1;
  $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);
  for ($X = 0; $X <= $this->GridSizeX; $X++) {
    for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
      $Value = $this->Points[$X][$Y];
      if ($Value != UNKNOWN && $Value != IGNORED) {
        $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 ($Palette != NULL) {
          if (isset($Palette[$Value]) && isset($Palette[$Value]["R"])) {
            $R = $Palette[$Value]["R"];
          }
          else {
            $R = 0;
          }
          if (isset($Palette[$Value]) && isset($Palette[$Value]["G"])) {
            $G = $Palette[$Value]["G"];
          }
          else {
            $G = 0;
          }
          if (isset($Palette[$Value]) && isset($Palette[$Value]["B"])) {
            $B = $Palette[$Value]["B"];
          }
          else {
            $B = 0;
          }
          if (isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"])) {
            $Alpha = $Palette[$Value]["Alpha"];
          }
          else {
            $Alpha = 1000;
          }
        }
        else {
          $R = ($ShadeR2 - $ShadeR1) / 100 * $Value + $ShadeR1;
          $G = ($ShadeG2 - $ShadeG1) / 100 * $Value + $ShadeG1;
          $B = ($ShadeB2 - $ShadeB1) / 100 * $Value + $ShadeB1;
          $Alpha = ($ShadeA2 - $ShadeA1) / 100 * $Value + $ShadeA1;
        }
        $Settings = array(
          "R" => $R,
          "G" => $G,
          "B" => $B,
          "Alpha" => $Alpha,
        );
        if ($Border) {
          $Settings["BorderR"] = $BorderR;
          $Settings["BorderG"] = $BorderG;
          $Settings["BorderB"] = $BorderB;
        }
        if ($Surrounding != -1) {
          $Settings["BorderR"] = $R + $Surrounding;
          $Settings["BorderG"] = $G + $Surrounding;
          $Settings["BorderB"] = $B + $Surrounding;
        }
        $this->pChartObject
          ->drawFilledRectangle($X1, $Y1, $X2 - 1, $Y2 - 1, $Settings);
      }
    }
  }
}