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


PHP ImagickDraw::circle方法代码示例

本文整理汇总了PHP中ImagickDraw::circle方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::circle方法的具体用法?PHP ImagickDraw::circle怎么用?PHP ImagickDraw::circle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImagickDraw的用法示例。


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

示例1: blueDiscAlpha

function blueDiscAlpha($width, $height)
{
    $imagick = new Imagick();
    $imagick->newImage($width, $height, 'none');
    $draw = new ImagickDraw();
    $draw->setStrokeOpacity(0);
    $draw->setFillColor('blue');
    $draw->circle(2 * $width / 3, 2 * $height / 3, $width - ($width / 3 - $width / 4), 2 * $height / 3);
    $imagick->drawImage($draw);
    return $imagick;
}
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:11,代码来源:createSourceImages.php

示例2: test_shape

function test_shape(&$canvas)
{
    $draw = new ImagickDraw();
    $draw->setFillColor('transparent');
    $draw->setStrokeColor('#F02B88');
    $draw->setStrokeWidth(9);
    $draw->translate(200, 100);
    $draw->rectangle(-50, -50, 50, 50);
    $draw->translate(200, 100);
    $draw->ellipse(0, 0, 100, 80, 0, 360);
    $draw->skewX(-30);
    $draw->translate(200, 100);
    $draw->circle(0, 0, 50, 50);
    $canvas->drawImage($draw);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:15,代码来源:draw_example.php

示例3: makeSimpleGif

function makeSimpleGif($deconstruct)
{
    $aniGif = new \Imagick();
    $aniGif->setFormat("gif");
    $circleRadius = 20;
    $imageFrames = 40;
    $imageSize = 200;
    $background = new \Imagick();
    $background->newpseudoimage($imageSize, $imageSize, "plasma:tomato-steelblue");
    $blackWhite = new \Imagick();
    $blackWhite->newpseudoimage($imageSize, $imageSize, "gradient:black-white");
    $backgroundPalette = clone $background;
    $backgroundPalette->quantizeImage(240, \Imagick::COLORSPACE_RGB, 8, false, false);
    $blackWhitePalette = clone $blackWhite;
    $blackWhitePalette->quantizeImage(16, \Imagick::COLORSPACE_RGB, 8, false, false);
    $backgroundPalette->addimage($blackWhitePalette);
    for ($count = 0; $count < $imageFrames; $count++) {
        $drawing = new \ImagickDraw();
        $drawing->setFillColor('white');
        $drawing->setStrokeColor('rgba(64, 64, 64, 0.8)');
        $strokeWidth = 4;
        $drawing->setStrokeWidth($strokeWidth);
        $distanceToMove = $imageSize + ($circleRadius + $strokeWidth) * 2;
        $offset = $distanceToMove * $count / ($imageFrames - 1) - ($circleRadius + $strokeWidth);
        $drawing->translate($offset, $imageSize / 2 + $imageSize / 3 * cos(20 * $count / $imageFrames));
        $drawing->circle(0, 0, $circleRadius, 0);
        $frame = clone $background;
        $frame->drawimage($drawing);
        $frame->clutimage($backgroundPalette);
        $frame->setImageDelay(10);
        $aniGif->addImage($frame);
    }
    if ($deconstruct == true) {
        $aniGif = $aniGif->deconstructImages();
    }
    header("Content-Type: image/gif");
    echo $aniGif->getImagesBlob();
}
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:38,代码来源:deconstructGif.php

示例4: drawBezierChart

 function drawBezierChart($points, $roundness)
 {
     //Calculate the tangent vector for each point that you're drawing.
     $tangents = $this->getPointTangents($points);
     $positions = $this->getPointPositions($points);
     $numberOfPoints = count($points);
     $this->draw->setFillColor('#B42AAF9F');
     $this->draw->translate($this->chartWidth / 2, $this->chartHeight / 2);
     $this->draw->pathStart();
     $this->draw->pathMoveToAbsolute($positions[0][0], $positions[0][1]);
     //Scale that by the 'value' of each point aka the distance from the chart's centre.
     //Also scale it by how rounded you want the chart.
     for ($i = 0; $i < $numberOfPoints; $i++) {
         list($nextPositionX, $nextPositionY) = $positions[($i + 1) % $numberOfPoints];
         list($controlPoint1X, $controlPoint1Y) = $this->getControlPoint($points[$i], $positions[$i], $tangents[$i], 1, $roundness, count($points));
         list($controlPoint2X, $controlPoint2Y) = $this->getControlPoint($points[($i + 1) % $numberOfPoints], $positions[($i + 1) % $numberOfPoints], $tangents[($i + 1) % $numberOfPoints], -1, $roundness, count($points));
         $this->draw->pathCurveToAbsolute($controlPoint1X, $controlPoint1Y, $controlPoint2X, $controlPoint2Y, $nextPositionX, $nextPositionY);
     }
     $this->draw->pathClose();
     $this->draw->pathFinish();
     foreach ($this->points as $point) {
         $this->draw->circle($point[0], $point[1], $point[2], $point[3]);
     }
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:24,代码来源:smoothSpiderGraph.php

示例5: getWhiteDisc

 function getWhiteDisc()
 {
     $width = $this->width;
     $height = $this->height;
     $imagick = new \Imagick();
     $imagick->newImage($width, $height, 'black');
     $draw = new \ImagickDraw();
     $draw->setStrokeOpacity(0);
     $draw->setFillColor('white');
     $draw->circle($width / 2, $height / 2, $width / 4, $height / 2);
     $imagick->drawImage($draw);
     return $imagick;
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:13,代码来源:composite.php

示例6: renderKernel

function renderKernel(ImagickKernel $imagickKernel)
{
    $matrix = $imagickKernel->getMatrix();
    $imageMargin = 20;
    $tileSize = 20;
    $tileSpace = 4;
    $shadowSigma = 4;
    $shadowDropX = 20;
    $shadowDropY = 0;
    $radius = $tileSize / 2 * 0.9;
    $rows = count($matrix);
    $columns = count($matrix[0]);
    $imagickDraw = new \ImagickDraw();
    $imagickDraw->setFillColor('#afafaf');
    $imagickDraw->setStrokeColor('none');
    $imagickDraw->translate($imageMargin, $imageMargin);
    $imagickDraw->push();
    ksort($matrix);
    foreach ($matrix as $row) {
        ksort($row);
        $imagickDraw->push();
        foreach ($row as $cell) {
            if ($cell !== false) {
                $color = intval(255 * $cell);
                $colorString = sprintf("rgb(%f, %f, %f)", $color, $color, $color);
                $imagickDraw->setFillColor($colorString);
                $imagickDraw->rectangle(0, 0, $tileSize, $tileSize);
            }
            $imagickDraw->translate($tileSize + $tileSpace, 0);
        }
        $imagickDraw->pop();
        $imagickDraw->translate(0, $tileSize + $tileSpace);
    }
    $imagickDraw->pop();
    $width = $columns * $tileSize + ($columns - 1) * $tileSpace;
    $height = $rows * $tileSize + ($rows - 1) * $tileSpace;
    $imagickDraw->push();
    $imagickDraw->translate($width / 2, $height / 2);
    $imagickDraw->setFillColor('rgba(0, 0, 0, 0)');
    $imagickDraw->setStrokeColor('white');
    $imagickDraw->circle(0, 0, $radius - 1, 0);
    $imagickDraw->setStrokeColor('black');
    $imagickDraw->circle(0, 0, $radius, 0);
    $imagickDraw->pop();
    $canvasWidth = $width + 2 * $imageMargin;
    $canvasHeight = $height + 2 * $imageMargin;
    $kernel = new \Imagick();
    $kernel->newPseudoImage($canvasWidth, $canvasHeight, 'canvas:none');
    $kernel->setImageFormat('png');
    $kernel->drawImage($imagickDraw);
    /* create drop shadow on it's own layer */
    $canvas = $kernel->clone();
    $canvas->setImageBackgroundColor(new \ImagickPixel('rgb(0, 0, 0)'));
    $canvas->shadowImage(100, $shadowSigma, $shadowDropX, $shadowDropY);
    $canvas->setImagePage($canvasWidth, $canvasHeight, -5, -5);
    $canvas->cropImage($canvasWidth, $canvasHeight, 0, 0);
    /* composite original text_layer onto shadow_layer */
    $canvas->compositeImage($kernel, \Imagick::COMPOSITE_OVER, 0, 0);
    $canvas->setImageFormat('png');
    return $canvas;
}
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:61,代码来源:functions.php

示例7: render

 public function render(\ImagickDraw $draw, $frame, $maxFrames, $phaseMultiplier, $phaseDivider)
 {
     $innerDistance = 40;
     $outerDistance = 230;
     $sequenceFraction = $this->sequence / $this->numberDots;
     $angle = 2 * M_PI * $sequenceFraction;
     $trailSteps = 5;
     $trailLength = 0.1;
     $offsets = [100 => 0];
     for ($i = 0; $i <= $trailSteps; $i++) {
         $key = intval(50 * $i / $trailSteps);
         $offsets[$key] = $trailLength * ($trailSteps - $i) / $trailSteps;
     }
     //TODO - using a pattern would make the circles look more natural
     //$draw->setFillPatternURL();
     foreach ($offsets as $alpha => $offset) {
         $distanceFraction = $this->calculateFraction($frame, $maxFrames, $offset, $phaseMultiplier, $phaseDivider);
         $distance = lerp($distanceFraction, $innerDistance, $outerDistance);
         $xOffset = $distance * sin($angle);
         $yOffset = $distance * cos($angle);
         $draw->setFillColor($this->color);
         $draw->setFillAlpha($alpha / 100);
         $xOffset = $xOffset * $this->imageWidth / 500;
         $yOffset = $yOffset * $this->imageHeight / 500;
         $xSize = 4 * $this->imageWidth / 500;
         $ySize = 4 * $this->imageHeight / 500;
         $draw->circle($xOffset, $yOffset, $xOffset + $xSize, $yOffset + $ySize);
     }
 }
开发者ID:biswajit-paul,项目名称:gittest,代码行数:29,代码来源:functions.php

示例8: opticrop

function opticrop($image, $w, $h, $out, $format)
{
    // source dimensions
    $imginfo = getimagesize($image);
    $w0 = $imginfo[0];
    $h0 = $imginfo[1];
    if ($w > $w0 || $h > $h0) {
        die("Target dimensions must be smaller or equal to source dimensions.");
    }
    // parameters for the edge-maximizing crop algorithm
    $r = 1;
    // radius of edge filter
    $nk = 9;
    // scale count: number of crop sizes to try
    $gamma = GAMMA;
    // edge normalization parameter -- see documentation
    $ar = $w / $h;
    // target aspect ratio (AR)
    $ar0 = $w0 / $h0;
    // target aspect ratio (AR)
    dprint(basename($image) . ": {$w0} x {$h0} => {$w} x {$h}");
    $img = new Imagick($image);
    $imgcp = clone $img;
    // compute center of edginess
    $img->edgeImage($r);
    $img->modulateImage(100, 0, 100);
    // grayscale
    $img->blackThresholdImage("#0f0f0f");
    $img->writeImage($out);
    // use gd for random pixel access
    $im = ImageCreateFromJpeg($out);
    $xcenter = 0;
    $ycenter = 0;
    $sum = 0;
    $n = 100000;
    for ($k = 0; $k < $n; $k++) {
        $i = mt_rand(0, $w0 - 1);
        $j = mt_rand(0, $h0 - 1);
        $val = imagecolorat($im, $i, $j) & 0xff;
        $sum += $val;
        $xcenter += ($i + 1) * $val;
        $ycenter += ($j + 1) * $val;
    }
    $xcenter /= $sum;
    $ycenter /= $sum;
    // crop source img to target AR
    if ($w0 / $h0 > $ar) {
        // source AR wider than target
        // crop width to target AR
        $wcrop0 = round($ar * $h0);
        $hcrop0 = $h0;
    } else {
        // crop height to target AR
        $wcrop0 = $w0;
        $hcrop0 = round($w0 / $ar);
    }
    // crop parameters for all scales and translations
    $params = array();
    // crop at different scales
    $hgap = $hcrop0 - $h;
    $hinc = $nk == 1 ? 0 : $hgap / ($nk - 1);
    $wgap = $wcrop0 - $w;
    $winc = $nk == 1 ? 0 : $wgap / ($nk - 1);
    // find window with highest normalized edginess
    $n = 10000;
    $maxbetanorm = 0;
    $maxfile = '';
    $maxparam = array('w' => 0, 'h' => 0, 'x' => 0, 'y' => 0);
    for ($k = 0; $k < $nk; $k++) {
        $hcrop = round($hcrop0 - $k * $hinc);
        $wcrop = round($wcrop0 - $k * $winc);
        $xcrop = $xcenter - $wcrop / 2;
        $ycrop = $ycenter - $hcrop / 2;
        dprint("crop: {$wcrop}, {$hcrop}, {$xcrop}, {$ycrop}");
        if ($xcrop < 0) {
            $xcrop = 0;
        }
        if ($xcrop + $wcrop > $w0) {
            $xcrop = $w0 - $wcrop;
        }
        if ($ycrop < 0) {
            $ycrop = 0;
        }
        if ($ycrop + $hcrop > $h0) {
            $ycrop = $h0 - $hcrop;
        }
        // debug
        $currfile = CACHE_PATH . "image{$k}.jpg";
        if (DEBUG > 0) {
            $currimg = clone $img;
            $c = new ImagickDraw();
            $c->setFillColor("red");
            $c->circle($xcenter, $ycenter, $xcenter, $ycenter + 4);
            $currimg->drawImage($c);
            $currimg->cropImage($wcrop, $hcrop, $xcrop, $ycrop);
            $currimg->writeImage($currfile);
            $currimg->destroy();
        }
        $beta = 0;
        for ($c = 0; $c < $n; $c++) {
//.........这里部分代码省略.........
开发者ID:jueseph,项目名称:Opticrop,代码行数:101,代码来源:opticrop.php

示例9: setImageClipMask

function setImageClipMask($imagePath)
{
    $imagick = new \Imagick();
    $imagick->readImage(realpath($imagePath));
    $width = $imagick->getImageWidth();
    $height = $imagick->getImageHeight();
    $clipMask = new \Imagick();
    $clipMask->newPseudoImage($width, $height, "canvas:transparent");
    $draw = new \ImagickDraw();
    $draw->setFillColor('white');
    $draw->circle($width / 2, $height / 2, $width / 2 + $width / 4, $height / 2);
    $clipMask->drawImage($draw);
    $imagick->setImageClipMask($clipMask);
    $imagick->negateImage(false);
    $imagick->setFormat("png");
    header("Content-Type: image/png");
    echo $imagick->getImagesBlob();
}
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:18,代码来源:functions.php

示例10: circle

 /**
  * Draw a circle.
  *
  * @param integer $x     The x coordinate of the centre.
  * @param integer $y     The y coordinate of the centre.
  * @param integer $r     The radius of the circle.
  * @param string $color  The line color of the circle.
  * @param string $fill   The color to fill the circle.
  */
 public function circle($x, $y, $r, $color, $fill = 'none')
 {
     $draw = new ImagickDraw();
     $draw->setFillColor(new ImagickPixel($fill));
     $draw->setStrokeColor(new ImagickPixel($color));
     $draw->circle($x, $y, $r + $x, $y);
     try {
         $res = $this->_imagick->drawImage($draw);
     } catch (ImagickException $e) {
         throw new Horde_Image_Exception($e);
     }
     $draw->destroy();
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:22,代码来源:Imagick.php

示例11: setViewBox

function setViewBox($strokeColor, $fillColor, $backgroundColor)
{
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    /*
         
        Sets the overall canvas size to be recorded with the drawing vector data. Usually this will be specified using the same size as the canvas image. When the vector data is saved to SVG or MVG formats, the viewbox is use to specify the size of the canvas image that a viewer will render the vector data on.
    */
    $draw->circle(250, 250, 250, 0);
    $draw->setviewbox(0, 0, 200, 200);
    $draw->circle(125, 250, 250, 250);
    $draw->translate(250, 125);
    $draw->circle(0, 0, 125, 0);
    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:23,代码来源:functions.php

示例12: ImagickDraw

        $draw = new ImagickDraw();
        $draw->setFont('Nimbus-Sans-Bold');
        if ($reqwidth <= 300) {
            $draw->setFontSize(9);
            $radius = 5;
        } else {
            if ($reqwidth < 800) {
                $draw->setFontSize(12);
                $radius = 7;
                $offset = 1;
            } else {
                $draw->setFontSize(14);
                $radius = 10;
                $offset = 2;
            }
        }
        foreach ($comments as $comment) {
            $draw->setFillColor('black');
            $x = $comment['x'] * $factor;
            $y = $comment['y'] * $factor;
            $draw->circle($x + $radius, $y + $radius, $x + $radius * 2, $y + $radius * 2);
            $draw->setFillColor('white');
            $draw->setTextAlignment(2);
            $draw->annotation($x + $radius, $y + $radius + $radius / 2 + 1, $comment['nr']);
        }
        $image->drawImage($draw);
        // Output
        header('Content-Type: image/png');
        echo $image;
        break;
}
开发者ID:nicam,项目名称:clarify,代码行数:31,代码来源:screen.php

示例13: gs_displayCircles

 private function gs_displayCircles()
 {
     $this->img = new Imagick($this->imagePath);
     $draw = new \ImagickDraw();
     $strokeColor = new \ImagickPixel("rgb(210,0,0)");
     $fillColor = new \ImagickPixel("rgba(0,0,0,0)");
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(1);
     for ($i = 0; $i < sizeof($this->data['extr']); $i++) {
         $p = $this->data['extr'][$i];
         $draw->circle($p['x'], $p['y'], $p['x'] + $p['sigma'] * 1.5, $p['y']);
     }
     $this->img->drawImage($draw);
 }
开发者ID:Atiragram,项目名称:poit-labs,代码行数:15,代码来源:fksistagram.php


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