Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageDraw
- WHITE = (255, 255, 255)
- BROWN = (139, 69, 19)
- GREEN = (0, 128, 0)
- def draw_tree(width, height):
- image = Image.new("RGB", (width, height), WHITE)
- draw = ImageDraw.Draw(image)
- draw.rectangle(((width * 0.45, height * 0.7), (width * 0.55, height * 0.9)), fill=BROWN)
- draw.polygon(((width * 0.4, height * 0.3),
- (width * 0.5, height * 0.1),
- (width * 0.6, height * 0.3)),
- GREEN)
- draw.polygon(((width * 0.35, height * 0.5),
- (width * 0.45, height * 0.3),
- (width * 0.55, height * 0.3),
- width * 0.65, height * 0.5),
- GREEN)
- draw.polygon(((width * 0.3, height * 0.7),
- (width * 0.4, height * 0.5),
- (width * 0.6, height * 0.5),
- width * 0.7, height * 0.7),
- GREEN)
- image.save("2.png")
- image.show()
- draw_tree(600, 600)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement