ImageMagick & Pie Charts

谁说我不能喝 提交于 2019-12-24 12:15:14

问题


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:


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.



来源:https://stackoverflow.com/questions/1430018/imagemagick-pie-charts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!