当前位置: 首页>>代码示例>>PHP>>正文


PHP imageColorExactAlpha函数代码示例

本文整理汇总了PHP中imageColorExactAlpha函数的典型用法代码示例。如果您正苦于以下问题:PHP imageColorExactAlpha函数的具体用法?PHP imageColorExactAlpha怎么用?PHP imageColorExactAlpha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imageColorExactAlpha函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: imagesmoothcircle

/**
 * Credits goes to an anonymous at http://usphp.com/manual/ro/function.imageantialias.php
 */
function imagesmoothcircle(&$img, $cx, $cy, $cr, $color)
{
    $ir = $cr;
    $ix = 0;
    $iy = $ir;
    $ig = 2 * $ir - 3;
    $idgr = -6;
    $idgd = 4 * $ir - 10;
    $fill = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 0);
    imageLine($img, $cx + $cr - 1, $cy, $cx, $cy, $fill);
    imageLine($img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill);
    imageLine($img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill);
    imageLine($img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill);
    $draw = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 42);
    imageSetPixel($img, $cx + $cr, $cy, $draw);
    imageSetPixel($img, $cx - $cr, $cy, $draw);
    imageSetPixel($img, $cx, $cy + $cr, $draw);
    imageSetPixel($img, $cx, $cy - $cr, $draw);
    while ($ix <= $iy - 2) {
        if ($ig < 0) {
            $ig += $idgd;
            $idgd -= 8;
            $iy--;
        } else {
            $ig += $idgr;
            $idgd -= 4;
        }
        $idgr -= 4;
        $ix++;
        imageLine($img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill);
        imageLine($img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill);
        imageLine($img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill);
        imageLine($img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill);
        imageLine($img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill);
        imageLine($img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill);
        imageLine($img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill);
        imageLine($img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill);
        $filled = 0;
        for ($xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2) {
            for ($yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2) {
                if (sqrt(pow($xx, 2) + pow($yy, 2)) < $cr) {
                    $filled += 4;
                }
            }
        }
        $draw = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 100 - $filled);
        imageSetPixel($img, $cx + $ix, $cy + $iy, $draw);
        imageSetPixel($img, $cx + $ix, $cy - $iy, $draw);
        imageSetPixel($img, $cx - $ix, $cy + $iy, $draw);
        imageSetPixel($img, $cx - $ix, $cy - $iy, $draw);
        imageSetPixel($img, $cx + $iy, $cy + $ix, $draw);
        imageSetPixel($img, $cx + $iy, $cy - $ix, $draw);
        imageSetPixel($img, $cx - $iy, $cy + $ix, $draw);
        imageSetPixel($img, $cx - $iy, $cy - $ix, $draw);
    }
}
开发者ID:bishopm,项目名称:circuit,代码行数:59,代码来源:gdext.inc.php

示例2: imageSmoothArcDrawSegment

function imageSmoothArcDrawSegment(&$img, $cx, $cy, $a, $b, $color, $start, $stop, $seg)
{
    // Originally written from scratch by Ulrich Mierendorff, 06/2006
    // Rewritten and improved, 04/2007, 07/2007
    // Optimized circle version: 03/2008
    // Please do not use THIS function directly. Scroll down to imageSmoothArc(...).
    $fillColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], $color[3]);
    switch ($seg) {
        case 0:
            $xp = +1;
            $yp = -1;
            $xa = 1;
            $ya = -1;
            break;
        case 1:
            $xp = -1;
            $yp = -1;
            $xa = 0;
            $ya = -1;
            break;
        case 2:
            $xp = -1;
            $yp = +1;
            $xa = 0;
            $ya = 0;
            break;
        case 3:
            $xp = +1;
            $yp = +1;
            $xa = 1;
            $ya = 0;
            break;
    }
    for ($x = 0; $x <= $a; $x += 1) {
        $y = $b * sqrt(1 - $x * $x / ($a * $a));
        $error = $y - (int) $y;
        $y = (int) $y;
        $diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y + 1) + $ya, $diffColor);
        imageLine($img, $cx + $xp * $x + $xa, $cy + $yp * $y + $ya, $cx + $xp * $x + $xa, $cy + $ya, $fillColor);
    }
    for ($y = 0; $y < $b; $y += 1) {
        $x = $a * sqrt(1 - $y * $y / ($b * $b));
        $error = $x - (int) $x;
        $x = (int) $x;
        $diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
        imageSetPixel($img, $cx + $xp * ($x + 1) + $xa, $cy + $yp * $y + $ya, $diffColor);
    }
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:49,代码来源:imageSmoothArc_optimized.php

示例3: _getColor

 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;
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:24,代码来源:ZBuffer.php

示例4: imageSmoothArcDrawSegment

function imageSmoothArcDrawSegment(&$img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY, $color, $start, $stop, $seg)
{
    // Originally written from scratch by Ulrich Mierendorff, 06/2006
    // Rewritten and improved, 04/2007, 07/2007
    // Please do not use THIS function directly. Scroll down to imageSmoothArc(...).
    $fillColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], $color[3]);
    $xStart = abs($a * cos($start));
    $yStart = abs($b * sin($start));
    $xStop = abs($a * cos($stop));
    $yStop = abs($b * sin($stop));
    $dxStart = 0;
    $dyStart = 0;
    $dxStop = 0;
    $dyStop = 0;
    if ($xStart != 0) {
        $dyStart = $yStart / $xStart;
    }
    if ($xStop != 0) {
        $dyStop = $yStop / $xStop;
    }
    if ($yStart != 0) {
        $dxStart = $xStart / $yStart;
    }
    if ($yStop != 0) {
        $dxStop = $xStop / $yStop;
    }
    if (abs($xStart) >= abs($yStart)) {
        $aaStartX = true;
    } else {
        $aaStartX = false;
    }
    if ($xStop >= $yStop) {
        $aaStopX = true;
    } else {
        $aaStopX = false;
    }
    //$xp = +1; $yp = -1; $xa = +1; $ya = 0;
    for ($x = 0; $x < $a; $x += 1) {
        /*$y = $b * sqrt( 1 - ($x*$x)/($a*$a) );
          
          $error = $y - (int)($y);
          $y = (int)($y);
          
          $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );*/
        $_y1 = $dyStop * $x;
        $_y2 = $dyStart * $x;
        if ($xStart > $xStop) {
            $error1 = $_y1 - (int) $_y1;
            $error2 = 1 - $_y2 + (int) $_y2;
            $_y1 = $_y1 - $error1;
            $_y2 = $_y2 + $error2;
        } else {
            $error1 = 1 - $_y1 + (int) $_y1;
            $error2 = $_y2 - (int) $_y2;
            $_y1 = $_y1 + $error1;
            $_y2 = $_y2 - $error2;
        }
        /*
        if ($aaStopX)
            $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 );
        if ($aaStartX)
            $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 );
        */
        if ($seg == 0 || $seg == 2) {
            $i = $seg;
            if (!($start > $i * M_PI / 2 && $x > $xStart)) {
                if ($i == 0) {
                    $xp = +1;
                    $yp = -1;
                    $xa = +1;
                    $ya = 0;
                } else {
                    $xp = -1;
                    $yp = +1;
                    $xa = 0;
                    $ya = +1;
                }
                if ($stop < ($i + 1) * (M_PI / 2) && $x <= $xStop) {
                    $diffColor1 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error1);
                    $y1 = $_y1;
                    if ($aaStopX) {
                        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor1);
                    }
                } else {
                    $y = $b * sqrt(1 - $x * $x / ($a * $a));
                    $error = $y - (int) $y;
                    $y = (int) $y;
                    $diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
                    $y1 = $y;
                    if ($x < $aaAngleX) {
                        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor);
                    }
                }
                if ($start > $i * M_PI / 2 && $x <= $xStart) {
                    $diffColor2 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error2);
                    $y2 = $_y2;
                    if ($aaStartX) {
                        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y2 - 1) + $ya, $diffColor2);
                    }
                } else {
//.........这里部分代码省略.........
开发者ID:gdbhosale,项目名称:fancy-qr-code-generator,代码行数:101,代码来源:imageSmoothArc.php


注:本文中的imageColorExactAlpha函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。