views:

494

answers:

3

Is there a way to get GD's function imagefilledarc()'s result in using PHP ImageMagick? I've looked around but haven't found a satisfying solution so far. I want it to support transparency, and use it to draw pies.

+1  A: 

Your best bet would be to use ImageMagick::Draw. It has an arc command; instead of specifying the center, you specify the bounding rectangle. You just need to add a command before it to set the fill, and perhaps after it to close the fill.

http://us.php.net/manual/en/function.imagickdraw-arc.php

Jeff Bowman
It doesn't work the same way. That command basically does an ellipse within the bounding box, cuts at a line between the given degrees and deletes one of the pieces.
antennen
+1  A: 

As far as I know ImagickDraw::arc is the only way to do it (unless you want to create a function that draws it pixel by pixel). But to get it working the same way as gd, you just have to make minor changes. For instance, this:

imagearc($image, $cx, $cy, $width, $height, $start, $end, $color);

Should be equivalent to this (I haven't tested it):

ImagickDraw::setStrokeColor($imageMagickColor);    //I don't remember how to allocate the color
ImagickDraw::arc($cx-$width/2, $cy-$height/2, $cx+$width/2, $cy+$height/2, $start, $end);
dutchflyboy
+2  A: 
dyve
That's not what I want. But thank you anyway.
antennen