2014-09-06 158 views
3

我只想得到如何用php5 imagemagick绘制圆圈的基本想法。 我看了页面,http://php.net/manual/en/imagickdraw.circle.php 但这个例子太混乱了。我想画一个圆圈,然后弄乱它。有人可以给我一个简单的php5 imagemagick圈子的例子吗?用php绘制圆圈imagemagick

我曾尝试:

<?php 
header("Content-type: image/jpeg"); 
$circle = new ImagickDraw(); 
$draw->circle (10, 10, 60, 10); 
//echo $circle; 
?> 

任何许多变体,但我不能让一个圆圈绘制。

+1

http://www.phpimagick.com/ImagickDraw/circle – Danack 2014-09-07 14:18:43

回答

1

DANAK php的聊天页面上有这个环节,它提供了一个积极的例子给我提供。 http://www.phpimagick.com/ImagickDraw/circle

的变量名是准确的描述, 和例子,很容易让我明白了是怎么回事。

function circle($strokeColor, $fillColor, $backgroundColor, $originX, $originY, $endX, $endY) { 

    //Create a ImagickDraw object to draw into. 
    $draw = new \ImagickDraw(); 

    $strokeColor = new \ImagickPixel($strokeColor); 
    $fillColor = new \ImagickPixel($fillColor); 

    $draw->setStrokeOpacity(1); 
    $draw->setStrokeColor($strokeColor); 
    $draw->setFillColor($fillColor); 

    $draw->setStrokeWidth(2); 
    $draw->setFontSize(72); 

    $draw->circle($originX, $originY, $endX, $endY); 

    $imagick = new \Imagick(); 
    $imagick->newImage(500, 500, $backgroundColor); 
    $imagick->setImageFormat("png"); 
    $imagick->drawImage($draw); 

    header("Content-Type: image/png"); 
    echo $imagick->getImageBlob(); 
} 
1

我希望这是你在找什么:

<?php 
$draw = new ImagickDraw(); 
//given that $x and $y are the coordinates of the centre, and $r the radius: 
$draw->circle ($x, $y, $x + $r, $y); 
?> 
+1

男人我真的不明白它。工作示例? x,y是起源?好的其他2 x&y是什么? $ draw-> circle(0,0,50,50,0); – j0h 2014-09-06 16:02:06

+0

试试这个$ draw-> circle(10,10,60,10); – 2014-09-06 17:22:35