You are here

function pChart::drawAlphaPixel in Visitors 7.0

Same name and namespace in other branches
  1. 8 pchart/pChart.inc \pChart::drawAlphaPixel()
1 call to pChart::drawAlphaPixel()
pChart::drawAntialiasPixel in pchart/pChart.inc

File

pchart/pChart.inc, line 2410

Class

pChart

Code

function drawAlphaPixel($X, $Y, $Alpha, $R, $G, $B) {
  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 ($X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize) {
    return -1;
  }
  $RGB2 = imagecolorat($this->Picture, $X, $Y);
  $R2 = $RGB2 >> 16 & 0xff;
  $G2 = $RGB2 >> 8 & 0xff;
  $B2 = $RGB2 & 0xff;
  $iAlpha = (100 - $Alpha) / 100;
  $Alpha = $Alpha / 100;
  $Ra = floor($R * $Alpha + $R2 * $iAlpha);
  $Ga = floor($G * $Alpha + $G2 * $iAlpha);
  $Ba = floor($B * $Alpha + $B2 * $iAlpha);
  $C_Aliased = imagecolorallocate($this->Picture, $Ra, $Ga, $Ba);
  imagesetpixel($this->Picture, $X, $Y, $C_Aliased);
}