#!python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2019/11/03 09:30:45 +0900> """ Draw for aggdraw. Windows10 x64 + Python 3.7.5 32bit + Pillow 6.2.1 + aggdraw 1.3.11 """ from PIL import Image import aggdraw # aggdraw im = Image.new('RGB', (512, 512), "white") d = aggdraw.Draw(im) pen = aggdraw.Pen("black", 4.0) # color, width brush = aggdraw.Brush("green") # color # line x0, y0 = 16, 16 x1, y1 = 240, 240 d.line((x0, y0, x1, y1, x1, y0, x0, y1), pen) # polygon lst = [ # x, y 384, 16, 272, 128, 320, 240, 448, 240, 496, 128, ] d.polygon(lst, pen, brush) # rectangle brush = aggdraw.Brush("orange") # color w, h = 96, 96 x0, y0 = 16, 256 + 16 x1, y1 = x0 + w, y0 + h d.rectangle((x0, y0, x1, y1), pen) x0, y0 = 128, 256 + 16 x1, y1 = x0 + w, y0 + h d.rectangle((x0, y0, x1, y1), brush) x0, y0 = 16, 256 + 128 x1, y1 = x0 + w, y0 + h d.rectangle((x0, y0, x1, y1), pen, brush) # ellipse w, h = 96, 96 x0, y0 = 256 + 16, 256 + 16 x1, y1 = x0 + w, y0 + h d.ellipse((x0, y0, x1, y1), pen) x0, y0 = 256 + 128, 256 + 16 x1, y1 = x0 + w, y0 + h d.ellipse((x0, y0, x1, y1), brush) x0, y0 = 256 + 16, 256 + 128 x1, y1 = x0 + w, y0 + h d.ellipse((x0, y0, x1, y1), pen, brush) # text ... Error # fnt = aggdraw.Font("blue", "arial.ttf", size=24) # d.text((100, 100), "use aggdraw") d.flush() im.show() # im.save("./output_aggdraw2.png")