Python PIL-绘制圆 [英] Python PIL - Draw Circle

查看:395
本文介绍了Python PIL-绘制圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制一个简单的圆,并使用Python Imaging Library将其保存到文件中:

I am trying to draw a simple circle and save this to a file using the Python Imaging Library:

import Image, ImageDraw

image = Image.new('RGBA', (200, 200))
draw = ImageDraw.Draw(image)
draw.ellipse((20, 180, 180, 20), fill = 'blue', outline ='blue')
draw.point((100, 100), 'red')
image.save('test.png')

draw.point出现在图像上,但是椭圆本身不出现.我尝试将模式更改为RGB(我认为该模式可能会影响显示的内容),但这并不能解决问题.

The point draw.point appears on the image, but the ellipse itself does not. I tried changing the mode to just RGB (I thought the mode might affect what is displayed), but this did not solve it.

我该如何解决?谢谢!

推荐答案

而不是指定右上和左下坐标,而是将它们交换为左上和右下坐标.

Instead of specifying the upper right and lower left coordinates, swap them to get the upper left and lower right.

draw.ellipse((20, 20, 180, 180), fill = 'blue', outline ='blue')

这篇关于Python PIL-绘制圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆