Python 3.x 如何清除python3枕头中的区域
如何在python3枕头中使用Python 3.x 如何清除python3枕头中的区域,python-3.x,python-imaging-library,Python 3.x,Python Imaging Library,如何在python3枕头中使用ImageDraw清除区域 im = Image.new('RGBA', (1200, 400), (0, 0, 0, 0)) draw = ImageDraw.Draw(im) ... draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0)) draw.text((100, 100), 'Hello World!', font=font, fill=(0, 0, 255, 255)) canvas.writ
ImageDraw
清除区域
im = Image.new('RGBA', (1200, 400), (0, 0, 0, 0))
draw = ImageDraw.Draw(im)
...
draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0))
draw.text((100, 100), 'Hello World!', font=font, fill=(0, 0, 255, 255))
canvas.write(im.tobytes())
我的想法是用fill=(0,0,0,0)
绘制一个矩形,但由于alpha
分量为0
,因此该矩形与图像混合后不会改变像素
我每秒更新一个图像60次,我无法重新绘制整个图像。错误在我的代码中的其他地方 要清除某个区域,只需拨打电话
draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0))
区域
(100100300150)
将用fill
参数中给出的颜色填充。在本例中,矩形完全没有混合。错误在我的代码中的其他地方
要清除某个区域,只需拨打电话
draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0))
区域(100100300150)
将用fill
参数中给出的颜色填充。在这种情况下,矩形完全不混合