function pDraw::drawAntialiasPixel

5.x pDraw.class.php pDraw::drawAntialiasPixel($X, $Y, $Format = "")
3 calls to pDraw::drawAntialiasPixel()
pDraw::drawCircle in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawLine in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawRoundedRectangle in inc/pchart/pchart/class/pDraw.class.php

File

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

Class

pDraw

Code

function drawAntialiasPixel($X, $Y, $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;

  if ($X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize) {
    return (-1);
  }

  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;
  }

  if (!$this->Antialias) 
   {
    if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) 
     {
      $ShadowColor = $this->allocateColor($this->Picture, $this->ShadowR, $this->ShadowG, $this->ShadowB, $this->Shadowa);
      imagesetpixel($this->Picture, $X + $this->ShadowX, $Y + $this->ShadowY, $ShadowColor);
    }

    $PlotColor = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
    imagesetpixel($this->Picture, $X, $Y, $PlotColor);

    return (0);
  }

  $Plot = "";
  $Xi = floor($X);
  $Yi = floor($Y);

  if ($Xi == $X && $Yi == $Y) 
   {
    if ($Alpha == 100) {
      $this->drawAlphaPixel($X, $Y, 100, $R, $G, $B);
    }
    else {
      $this->drawAlphaPixel($X, $Y, $Alpha, $R, $G, $B);
    }
  }
  else 
   {
    $Alpha1 = (((1 - ($X - floor($X))) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
    if ($Alpha1 > $this->AntialiasQuality) {
      $this->drawAlphaPixel($Xi, $Yi, $Alpha1, $R, $G, $B);
    }

    $Alpha2 = ((($X - floor($X)) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
    if ($Alpha2 > $this->AntialiasQuality) {
      $this->drawAlphaPixel($Xi + 1, $Yi, $Alpha2, $R, $G, $B);
    }

    $Alpha3 = (((1 - ($X - floor($X))) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
    if ($Alpha3 > $this->AntialiasQuality) {
      $this->drawAlphaPixel($Xi, $Yi + 1, $Alpha3, $R, $G, $B);
    }

    $Alpha4 = ((($X - floor($X)) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
    if ($Alpha4 > $this->AntialiasQuality) {
      $this->drawAlphaPixel($Xi + 1, $Yi + 1, $Alpha4, $R, $G, $B);
    }
  }
}