views:

251

answers:

1

What is the most direct way to draw a pie chart using ImageMagick in an existing image. For example, how would I draw a single slice given the following inputs?

  • A center point (x,y)
  • Radius
  • Percent
+1  A: 

Create your pie wedge using SVG; I got my example from here:

<svg>
<path d="M200,200 L200,20 A180,180 0 0,1 377,231 z"
 style="fill:#ff0000;
  fill-opacity: 1;
  stroke:black;
  stroke-width: 1"/>
</svg>

Then, overlay that image using ImageMagick to your background image.

composite.exe -background none -size 200x200 .\pie_wedge.svg .\background.png out.png

Note that you have to define your arcs with cartesian coordinates instead of radius, but the conversion should be fairly straightforward.

Jason R. Coombs