protected function _getColor(Image_3D_Color $color, $alpha = 1.0) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); $values[3] = (int) round((1 - (1 - $values[3]) * $alpha) * 127); if ($values[3] > 0) { // Tranzparente Farbe allokieren $color = imageColorExactAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]); if ($color === -1) { // Wenn nicht Farbe neu alloziieren $color = imageColorAllocateAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]); } } else { // Deckende Farbe allozieren $color = imageColorExact($this->_image, $values[0], $values[1], $values[2]); if ($color === -1) { // Wenn nicht Farbe neu alloziieren $color = imageColorAllocate($this->_image, $values[0], $values[1], $values[2]); } } return $color; }
function drawPieFade($img, $centerX, $centerY, $elWidth, $elHeight, $arcStart, $arcEnd, $hexadecimalStartColor, $hexadecimalEndColor) { $this->chartDiameter; $startColor = $this->getRGBColor($hexadecimalStartColor); $redStartColor = $startColor["red"]; $greenStartColor = $startColor["green"]; $blueStartColor = $startColor["blue"]; $endColor = $this->getRGBColor($hexadecimalEndColor); $redEndColor = $endColor["red"]; $greenEndColor = $endColor["green"]; $blueEndColor = $endColor["blue"]; $redSteps = $this->calculateDifference($redStartColor, $redEndColor); $greenSteps = $this->calculateDifference($greenStartColor, $greenEndColor); $blueSteps = $this->calculateDifference($blueStartColor, $blueEndColor); $redStep = $redSteps / ($arcEnd - $arcStart); $greenStep = $greenSteps / ($arcEnd - $arcStart); $blueStep = $blueSteps / ($arcEnd - $arcStart); $steps = round($this->chartDiameter / 4); $mx = $this->chartDiameter / 2; $i = ceil($mx / 4); while ($i--) { $color = imageColorExact($img, $this->getFadeColor($redStartColor, $redEndColor, $i, $redStep), $this->getFadeColor($greenStartColor, $greenEndColor, $i, $greenStep), $this->getFadeColor($blueStartColor, $blueEndColor, $i, $blueStep)); // check for duplicate colors, don't allocate them if ($color == -1) { $color = ImageColorAllocate($img, $this->getFadeColor($redStartColor, $redEndColor, $i, $redStep), $this->getFadeColor($greenStartColor, $greenEndColor, $i, $greenStep), $this->getFadeColor($blueStartColor, $blueEndColor, $i, $blueStep)); } //draw arc imagearc($img, $this->chartCenterX, $this->chartCenterY, $mx - $i, $mx - $i, $arcStart, $arcEnd, $color); //draw start line from center list($ArcX, $ArcY) = $this->circle_point($arcStart, $mx - $i); imageline($img, $this->chartCenterX, $this->chartCenterY, floor($this->chartCenterX + $ArcX), floor($this->chartCenterY + $ArcY), $color); //draw end line from center list($ArcX, $ArcY) = $this->circle_point($arcEnd, $mx - $i); imageline($img, $this->chartCenterX, $this->chartCenterY, ceil($this->chartCenterX + $ArcX), ceil($this->chartCenterY + $ArcY), $color); //fill slice $MidPoint = round(($arcEnd - $arcStart) / 2 + $arcStart); list($ArcX, $ArcY) = $this->circle_point($MidPoint, ($mx - $i) / 2); //imagefilltoborder($img, floor($this->chartCenterX + $ArcX), floor($this->chartCenterY + $ArcY), $color,$color); } }
function drawBackgroundFade($img, $x1, $y1, $x2, $y2, $hexadecimalStartColor, $hexadecimalEndColor, $fadeDirection = FADE_VERTICAL) { $height = $y2; $width = $x2; // echo $hexadecimalStartColor, ' ' , $hexadecimalEndColor , '<br />'; $startColor = $this->getRGBColor($hexadecimalStartColor); $redStartColor = $startColor["red"]; $greenStartColor = $startColor["green"]; $blueStartColor = $startColor["blue"]; $endColor = $this->getRGBColor($hexadecimalEndColor); $redEndColor = $endColor["red"]; $greenEndColor = $endColor["green"]; $blueEndColor = $endColor["blue"]; $redSteps = $this->calculateDifference($redStartColor, $redEndColor); $greenSteps = $this->calculateDifference($greenStartColor, $greenEndColor); $blueSteps = $this->calculateDifference($blueStartColor, $blueEndColor); if ($fadeDirection == FADE_HORIZONTAL) { // height of each individual color block $redStep = $redSteps / $height; $greenStep = $greenSteps / $height; $blueStep = $blueSteps / $height; $i = $height; while ($i > 0) { $color = imageColorExact($img, $this->getFadeColor($redStartColor, $redEndColor, $i, $redStep), $this->getFadeColor($greenStartColor, $greenEndColor, $i, $greenStep), $this->getFadeColor($blueStartColor, $blueEndColor, $i, $blueStep)); // check for duplicate colors, don't allocate them if ($color == -1) { $color = ImageColorAllocate($img, $this->getFadeColor($redStartColor, $redEndColor, $i, $redStep), $this->getFadeColor($greenStartColor, $greenEndColor, $i, $greenStep), $this->getFadeColor($blueStartColor, $blueEndColor, $i, $blueStep)); } imageLine($img, $x1, $i + $y1, $x1 + $width, $i + $y1, $color); $i--; } } else { // height of each individual color block $redStep = $redSteps / $width; $greenStep = $greenSteps / $width; $blueStep = $blueSteps / $width; $i = $width; while ($i > 0) { $color = imageColorExact($img, $this->getFadeColor($redStartColor, $redEndColor, $i, $redStep), $this->getFadeColor($greenStartColor, $greenEndColor, $i, $greenStep), $this->getFadeColor($blueStartColor, $blueEndColor, $i, $blueStep)); // check for duplicate colors, don't allocate them if ($color == -1) { $color = ImageColorAllocate($img, $this->getFadeColor($redStartColor, $redEndColor, $i, $redStep), $this->getFadeColor($greenStartColor, $greenEndColor, $i, $greenStep), $this->getFadeColor($blueStartColor, $blueEndColor, $i, $blueStep)); } imageLine($img, $i + $x1, $y1, $x1 + $i, $height + $y1, $color); $i--; } } }