Skip to content

Instantly share code, notes, and snippets.

Avatar
🍱
spring is coming

xiaopc

🍱
spring is coming
View GitHub Profile
@xiaopc
xiaopc / draw_table.py
Last active Feb 16, 2021
Draw a table using only Pillow
View draw_table.py
from PIL import Image, ImageFont, ImageDraw
from collections import namedtuple
def position_tuple(*args):
Position = namedtuple('Position', ['top', 'right', 'bottom', 'left'])
if len(args) == 0:
return Position(0, 0, 0, 0)
elif len(args) == 1:
return Position(args[0], args[0], args[0], args[0])