Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import ImageDraw
- class ImageDrawer(ImageDraw.ImageDraw):
- def horizontal_trapezium(self, xy, width, height, fill=None, outline=None):
- x, y = xy
- up = (width[0] - width[-1]) // 2
- if width[0] > width[-1]:
- self.polygon([(x, y), (x + width[0], y), (x + width[-1] + up, height + y), (x + up, height + y)],
- fill=fill, outline=outline)
- else:
- self.polygon([(x + -up, y), (x + width[0] + -up, y), (x + width[-1], y + height), (x, y + height)],
- fill=fill, outline=outline)
- def vertical_trapezium(self, xy, width, height, fill=None, outline=None):
- x, y = xy
- up = (max(height) - min(height)) // 2
- if height[0] > height[-1]:
- self.polygon([(x, y), (x, y + height[0]), (x + width, y + up + height[-1]), (x + width, y + up)],
- fill=fill, outline=outline)
- else:
- self.polygon([(x, y + up), (x, y + height[0] + up), (x + width, y + height[-1]), (x + width, y)],
- fill=fill, outline=outline)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement