使用PIL用剪贴蒙版绘制渐变?
PIL(Python 图像库)是否有绘制线性渐变或/和设置剪切路径的方法?
我到处都找过,但找不到任何演示如何使用其中任何一个的示例。或者还有其他图形库可以完成类似的任务吗?
Does PIL (Python Imaging Library) have methods to draw linear gradients or/and set clipping paths?
I've looked everywhere but I can't find any examples that demonstrate how to use either. Or are there any other graphics libraries that can do similar tasks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定 PIL,但既然您也询问了替代方案,这里有一个使用 wxPython 的线性渐变和剪切区域的示例。
wxPython 并不严格用于图像处理,但它可以完成这项工作。
该程序的输出:
此示例使用标准绘图上下文,但还有
GraphicsContext 提供附加功能和更好的渲染(抗锯齿):
http://www.wxpython.org/docs/api/wx.GraphicsContext-class.html
I'm not sure about PIL, but since you asked about alternatives as well, here's an example of both linear gradients and clipping regions using wxPython.
wxPython isn't strictly for image manipulation but it can get the job done.
Output of this program:
This example uses a standard drawing context, but there's also
GraphicsContext
which provides additional functionality and better rendering (anti-aliasing):http://www.wxpython.org/docs/api/wx.GraphicsContext-class.html