1 from PIL import Image, ImageDraw
4 def draw_wu_line(draw, x, y, w, h):
5 # Without loss of generality only lines in the first oc
6 assert w > 0 and h > 0 and w > h
12 draw.point([(x, y )], fill=(0, 0, 0, 0xff - intensity))
13 draw.point([(x, y + 1)], fill=(0, 0, 0, intensity))
22 im = Image.new('RGBA', size)
23 d = ImageDraw.Draw(im, 'RGBA')
26 #draw_wu_line(d, 0, 0, *size)
29 #draw_wu_line(d, 0, 0, 51, 50)
31 # Nearly horizontal line.
32 #draw_wu_line(d, 0, 0, 100, 5)
34 draw_wu_line(d, 0, 0, 100, 33)
36 base = Image.new('RGBA', size, (0xff, 0xff, 0xff, 0xff))
37 base.alpha_composite(im)
38 base.save('wu_demo.png')