function pDraw::drawCircle

5.x pDraw.class.php pDraw::drawCircle($Xc, $Yc, $Height, $Width, $Format = "")
2 calls to pDraw::drawCircle()
pDraw::drawFilledCircle in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawShape in inc/pchart/pchart/class/pDraw.class.php

File

inc/pchart/pchart/class/pDraw.class.php, line 846

Class

pDraw

Code

function drawCircle($Xc, $Yc, $Height, $Width, $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"] : NULL;

  $Height = abs($Height);
  $Width = abs($Width);

  if ($Height == 0) {
    $Height = 1;
  }
  if ($Width == 0) {
    $Width = 1;
  }
  $Xc = floor($Xc);
  $Yc = floor($Yc);

  $RestoreShadow = $this->Shadow;
  if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) 
   {
    $this->Shadow = FALSE;
    $this->drawCircle($Xc + $this->ShadowX, $Yc + $this->ShadowY, $Height, $Width, array("R" => $this->ShadowR, "G" => $this->ShadowG, "B" => $this->ShadowB, "Alpha" => $this->Shadowa, "Ticks" => $Ticks));
  }

  if ($Width == 0) {
    $Width = $Height;
  }
  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;
  }

  $Step = 360 / (2 * PI * max($Width, $Height));
  $Mode = 1;
  $Cpt = 1;
  for ($i = 0; $i <= 360; $i = $i + $Step) 
   {
    $X = cos($i * PI / 180) * $Height + $Xc;
    $Y = sin($i * PI / 180) * $Width + $Yc;

    if ($Ticks != NULL) 
     {
      if ($Cpt % $Ticks == 0) 
       {
        $Cpt = 0;
        if ($Mode == 1) {
          $Mode = 0;
        }
        else {
          $Mode = 1;
        }
      }

      if ($Mode == 1) {
        $this->drawAntialiasPixel($X, $Y, array("R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha));
      }

      $Cpt++;
    }
    else {
      $this->drawAntialiasPixel($X, $Y, array("R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha));
    }

  }
  $this->Shadow = $RestoreShadow;
}