You are here

function pChart::drawDottedLine in Visitors 7.0

Same name and namespace in other branches
  1. 8 pchart/pChart.inc \pChart::drawDottedLine()
4 calls to pChart::drawDottedLine()
pChart::drawGrid in pchart/pChart.inc
pChart::drawLine in pchart/pChart.inc
pChart::drawRadarAxis in pchart/pChart.inc
pChart::drawTreshold in pchart/pChart.inc

File

pchart/pChart.inc, line 2342

Class

pChart

Code

function drawDottedLine($X1, $Y1, $X2, $Y2, $DotSize, $R, $G, $B, $GraphFunction = FALSE) {
  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;
  }
  $Distance = sqrt(($X2 - $X1) * ($X2 - $X1) + ($Y2 - $Y1) * ($Y2 - $Y1));
  $XStep = ($X2 - $X1) / $Distance;
  $YStep = ($Y2 - $Y1) / $Distance;
  $DotIndex = 0;
  for ($i = 0; $i <= $Distance; $i++) {
    $X = $i * $XStep + $X1;
    $Y = $i * $YStep + $Y1;
    if ($DotIndex <= $DotSize) {
      if ($X >= $this->GArea_X1 && $X <= $this->GArea_X2 && $Y >= $this->GArea_Y1 && $Y <= $this->GArea_Y2 || !$GraphFunction) {
        if ($this->LineWidth == 1) {
          $this
            ->drawAntialiasPixel($X, $Y, $R, $G, $B);
        }
        else {
          $StartOffset = -($this->LineWidth / 2);
          $EndOffset = $this->LineWidth / 2;
          for ($j = $StartOffset; $j <= $EndOffset; $j++) {
            $this
              ->drawAntialiasPixel($X + $j, $Y + $j, $R, $G, $B);
          }
        }
      }
    }
    $DotIndex++;
    if ($DotIndex == $DotSize * 2) {
      $DotIndex = 0;
    }
  }
}