from pathlib import Path
from PIL import Image, ImageDraw

# Draw directly on the final pixel grid; no antialiasing.
image = Image.new("RGBA", (32, 32), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
outline = "#222735"

# Oak haft, running from lower left to upper right.
draw.polygon([(4, 26), (21, 9), (24, 12), (7, 29), (4, 29)], fill=outline)
draw.line([(6, 27), (22, 11)], fill="#8c4e2b", width=3)
draw.line([(6, 26), (21, 11)], fill="#dfaa60", width=1)
draw.line([(7, 28), (23, 12)], fill="#603721", width=1)
draw.point((5, 28), fill="#dfaa60")

# Broad forged head with a stepped, convex cutting edge.
draw.polygon([
    (12, 3), (16, 3), (19, 6), (23, 8), (27, 8),
    (29, 10), (26, 13), (23, 12), (20, 12),
    (18, 16), (14, 19), (10, 17), (7, 14),
    (5, 10), (5, 7), (8, 6), (10, 5)
], fill=outline)
draw.polygon([
    (12, 4), (15, 4), (18, 7), (22, 9), (25, 9),
    (25, 11), (20, 10), (18, 13), (17, 15),
    (14, 17), (11, 15), (8, 12), (7, 8), (10, 7)
], fill="#788c9d")
draw.polygon([(12, 4), (15, 4), (18, 7), (20, 8), (17, 9), (13, 7), (9, 9), (7, 8), (10, 7)], fill="#b5c9d2")
draw.polygon([(17, 10), (20, 9), (23, 10), (20, 11), (17, 15), (14, 17), (12, 15)], fill="#4b6175")

# Bright sharpened edge follows the stair-stepped silhouette.
draw.line([(6, 7), (6, 10), (8, 14), (11, 17), (14, 18), (17, 16)], fill="#e5f3ed", width=1)
draw.line([(7, 9), (8, 12), (11, 15), (14, 17)], fill="#b5c9d2", width=1)

# Socket and squared poll.
draw.polygon([(21, 8), (24, 9), (25, 11), (23, 13), (20, 10)], fill=outline)
draw.line([(22, 9), (24, 11)], fill="#c1d2d8", width=1)
draw.line([(21, 10), (23, 12)], fill="#63798b", width=1)
draw.polygon([(26, 9), (27, 9), (28, 10), (26, 12), (25, 11)], fill="#94a9b7")
draw.point((27, 10), fill="#e5f3ed")

output = Path(__file__).parent
image.save(output / "axe_32x32.png")
image.resize((512, 512), Image.Resampling.NEAREST).save(output / "axe_preview.png")
