from pathlib import Path from PIL import Image, ImageDraw def draw_bow(): """Draw directly on a 32×32 canvas, without antialiasing.""" image = Image.new("RGBA", (32, 32), (0, 0, 0, 0)) draw = ImageDraw.Draw(image) outline = "#352738" wood = "#A85C35" light = "#EDAF62" gold = "#F7D58A" # The taut string connects the tips on the left of the curved limbs. draw.line([(10, 3), (10, 28)], fill="#786576", width=1) draw.line([(10, 5), (10, 26)], fill="#E9DEBA", width=1) # Stepped silhouettes keep each pixel crisp at the native resolution. draw.polygon( [(8, 2), (11, 2), (12, 4), (16, 5), (19, 7), (21, 10), (22, 13), (23, 14), (23, 17), (22, 18), (21, 21), (19, 24), (16, 26), (12, 27), (11, 29), (8, 29), (9, 26), (13, 24), (16, 22), (18, 19), (19, 17), (19, 14), (18, 12), (16, 9), (13, 7), (9, 5)], fill=outline, ) draw.line([(10, 3), (11, 5), (15, 6), (18, 8), (20, 11), (21, 14)], fill=wood, width=2) draw.line([(21, 17), (20, 20), (18, 23), (15, 25), (11, 26), (10, 28)], fill=wood, width=2) draw.line([(12, 5), (16, 6), (19, 9), (21, 13)], fill=light) draw.line([(21, 19), (19, 23), (16, 25), (12, 26)], fill=light) # Gold collars and a dark, leather-wrapped grip. draw.rectangle((19, 12, 22, 13), fill=outline) draw.line((20, 12, 21, 12), fill=gold) draw.rectangle((19, 14, 23, 17), fill=outline) draw.rectangle((20, 14, 22, 17), fill="#654354") draw.point((20, 14), fill="#B58171") draw.line((20, 16, 22, 15), fill="#B58171") draw.point((22, 17), fill="#B58171") draw.rectangle((19, 18, 22, 19), fill=outline) draw.line((20, 19, 21, 19), fill=gold) draw.point((10, 3), fill=gold) draw.point((10, 28), fill=gold) return image if __name__ == "__main__": destination = Path(__file__).with_name("archery_bow.png") image = draw_bow() image.save(destination) assert image.size == (32, 32) assert image.mode == "RGBA" print(destination)