示例#1
0
 public function _TransHor3D($aGdImg, $aHorizon = 100, $aSkewDist = 120, $aDir = SKEW3D_LEFT, $aMinSize = true, $aFillColor = '#FFFFFF', $aQuality = false, $aBorder = false, $aHorizonPos = 0.5)
 {
     $w = imagesx($aGdImg);
     $h = imagesy($aGdImg);
     // Create new image
     $hh = $h;
     if ($aMinSize) {
         $ww = ceil($w * $aHorizon / ($aSkewDist + $w));
     } else {
         $ww = $w;
     }
     $newgdh = imagecreatetruecolor($ww, $hh);
     $crgb = new RGB($newgdh);
     $fillColor = $crgb->Allocate($aFillColor);
     imagefilledrectangle($newgdh, 0, 0, $ww - 1, $hh - 1, $fillColor);
     if ($aBorder) {
         $colidx = $crgb->Allocate($aBorder);
         imagerectangle($newgdh, 0, 0, $ww - 1, $hh - 1, $colidx);
     }
     $mid = round($h * $aHorizonPos);
     $last = -1;
     for ($x = 0; $x < $w - 1; ++$x) {
         $xt = floor($x * $aHorizon / ($aSkewDist + $x));
         if (!$aQuality) {
             if ($last >= $xt) {
                 continue;
             }
             $last = $xt;
         }
         for ($y = 0; $y < $h; ++$y) {
             $yp = $h - $y - 1;
             $yt = ($yp - $mid) * $aSkewDist / ($aSkewDist + $x);
             if ($aDir == SKEW3D_RIGHT) {
                 $rgb = imagecolorat($aGdImg, $w - $x - 1, $y);
             } else {
                 $rgb = imagecolorat($aGdImg, $x, $y);
             }
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $colidx = imagecolorallocate($newgdh, $r, $g, $b);
             $yt = floor($hh - $yt - $mid - 1);
             if ($aDir == SKEW3D_RIGHT) {
                 $sxt = $ww - $xt - 1;
             } else {
                 $sxt = $xt;
             }
             if (!empty($set[$xt])) {
                 $nrgb = imagecolorat($newgdh, $sxt, $yt);
                 $nr = $nrgb >> 16 & 0xff;
                 $ng = $nrgb >> 8 & 0xff;
                 $nb = $nrgb & 0xff;
                 $colidx = imagecolorallocate($newgdh, floor(($r + $nr) / 2), floor(($g + $ng) / 2), floor(($b + $nb) / 2));
             }
             imagesetpixel($newgdh, $sxt, $yt, $colidx);
         }
         $set[$xt] = true;
     }
     return $newgdh;
 }
示例#2
0
 public function SetFillColor($aColor)
 {
     // Do an extra error check if the color is specified as an RGB array triple
     // In that case convert it to a hex string since it will otherwise be
     // interpretated as an array of colors for each individual bar.
     $aColor = Image\RGB::tryHexConversion($aColor);
     $this->fill = true;
     $this->fill_color = $aColor;
 }
示例#3
0
 /**
  * Calculate suitable colors for each defined isobar
  *
  */
 public function CalculateColors()
 {
     if ($this->highcontrast) {
         if ($this->highcontrastbw) {
             for ($ib = 0; $ib < $this->nbrIsobars; $ib++) {
                 $this->isobarColors[$ib] = 'black';
             }
         } else {
             // Use only blue/red scale
             $step = round(255 / ($this->nbrIsobars - 1));
             for ($ib = 0; $ib < $this->nbrIsobars; $ib++) {
                 $this->isobarColors[$ib] = array($ib * $step, 50, 255 - $ib * $step);
             }
         }
     } else {
         $n = $this->nbrIsobars;
         $v = 0;
         $step = 1 / ($this->nbrIsobars - 1);
         for ($ib = 0; $ib < $this->nbrIsobars; $ib++) {
             $this->isobarColors[$ib] = Image\RGB::GetSpectrum($v);
             $v += $step;
         }
     }
 }