"""Draw a 32x32 pixel-art archery bow. Requires Pillow.""" from pathlib import Path from PIL import Image, ImageDraw def draw_bow(): image = Image.new("RGBA", (32, 32), (0, 0, 0, 0)) draw = ImageDraw.Draw(image) outline = "#352333" wood = "#B96732" gold = "#E8A64B" light = "#FFDA7A" # Taut string, tucked under the two carved limb tips. draw.line([(9, 4), (9, 27)], fill="#888A9B", width=1) draw.line([(10, 4), (10, 27)], fill="#EEE5CF", width=1) # A stepped silhouette keeps every edge aligned with the pixel grid. limb = [ (8, 2), (11, 2), (11, 3), (14, 3), (14, 4), (16, 4), (16, 6), (18, 6), (18, 8), (20, 8), (20, 11), (22, 11), (22, 14), (23, 14), (23, 17), (22, 17), (22, 20), (20, 20), (20, 23), (18, 23), (18, 25), (16, 25), (16, 27), (14, 27), (14, 28), (11, 28), (11, 29), (8, 29), (8, 27), (11, 26), (13, 25), (15, 23), (16, 21), (17, 18), (18, 16), (18, 15), (17, 13), (16, 10), (15, 8), (13, 6), (11, 5), (8, 4), ] draw.polygon(limb, fill=outline) draw.line([(10, 3), (13, 4), (15, 6), (17, 8), (18, 11), (20, 14), (20, 17), (18, 20), (17, 23), (15, 25), (13, 27), (10, 28)], fill=wood, width=2) draw.line([(11, 3), (14, 4), (16, 6), (18, 9), (19, 12), (20, 14)], fill=gold, width=1) draw.line([(20, 18), (19, 21), (18, 23), (16, 25), (14, 27), (11, 28)], fill=gold, width=1) for point in [(12, 3), (15, 5), (17, 7), (18, 10), (18, 22), (16, 25), (13, 27)]: draw.point(point, fill=light) # Dark leather grip with staggered warm highlights. draw.rectangle((18, 13, 22, 18), fill=outline) draw.rectangle((19, 13, 21, 18), fill="#6C3C3B") for y in (13, 15, 17): draw.line([(19, y), (21, y + 1)], fill="#BC7B5A") draw.point((19, 13), fill="#E7B17B") draw.point((19, 17), fill="#E7B17B") # Small horn nocks at the string attachment points. draw.line([(9, 3), (10, 3)], fill=light) draw.line([(9, 28), (10, 28)], fill=light) return image if __name__ == "__main__": directory = Path(__file__).resolve().parent bow = draw_bow() bow.save(directory / "archery_bow_32x32.png") bow.resize((512, 512), Image.Resampling.NEAREST).save( directory / "archery_bow_preview.png" )