from PIL import Image, ImageDraw
from pathlib import Path

# Draw directly at native resolution: no antialiasing or downsampling.
image = Image.new('RGBA', (32, 32), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
outline = '#39251F'
wood = '#A65F32'
light = '#E4AE61'

# A taut bowstring runs between the two recurved tips.
draw.line([(10, 3), (10, 28)], fill='#796B55', width=1)
draw.line([(11, 4), (11, 27)], fill='#EADBB2', width=1)

# Broad, stepped limbs curve around the grip on the right.
limb = [(9, 2), (12, 2), (12, 4), (15, 5), (18, 7),
        (20, 10), (21, 13), (22, 14), (22, 17), (21, 18),
        (20, 21), (18, 24), (15, 26), (12, 27), (12, 29),
        (9, 29), (9, 26), (12, 24), (15, 22), (17, 19),
        (18, 16), (18, 15), (17, 12), (15, 9), (12, 7), (9, 5)]
draw.polygon(limb, fill=outline)
draw.line([(11, 3), (11, 5), (14, 6), (17, 8), (19, 11),
           (20, 14), (20, 17), (19, 20), (17, 23), (14, 25),
           (11, 26), (11, 28)], fill=wood, width=2)
draw.line([(12, 5), (15, 6), (18, 9), (19, 12)], fill=light)
draw.line([(19, 19), (18, 22), (15, 25), (12, 26)], fill=light)

# Dark leather grip with warm diagonal wrap stitches and brass collars.
draw.rectangle((18, 13, 22, 18), fill=outline)
draw.rectangle((19, 14, 21, 17), fill='#674638')
for y in (14, 16):
    draw.line([(19, y), (21, y + 1)], fill='#BD8860')
draw.line([(19, 13), (21, 13)], fill='#D4AC58')
draw.line([(19, 18), (21, 18)], fill='#D4AC58')

out = Path(__file__).parent
image.save(out / 'archery_bow_32x32.png')
image.resize((512, 512), Image.Resampling.NEAREST).save(out / 'archery_bow_preview.png')
print('Exported transparent 32x32 PNG and 512x512 pixel preview.')
