"""English twin of tools/dsh_figure.py: crop the last DSH screenshot to the final question, answer and usage bar,
and box the token numbers (2.1 figure). Crop boxes re-measured on assets/ch02_01_en/dsh_turn6.png (2200x1520).
Usage (textbook repo root): /Users/grapeot/co/knowledge_working/.venv/bin/python experiments_en/2_1_stateless/dsh_figure_en.py
"""
from PIL import Image, ImageDraw
src = 'assets/ch02_01_en/dsh_turn6.png'; dst = 'assets/ch02_01_en/dsh_usage.png'
im = Image.open(src).convert('RGB')
d = ImageDraw.Draw(im)
GREEN = (35, 131, 67)
for box in [(766, 1178, 1018, 1232),      # per-turn "Usage 19.2K tok"
            (1100, 1462, 1470, 1518),     # session "113K tok · Cache hit 94%"
            (1496, 1462, 1604, 1518)]:    # context meter "2%"
    d.rounded_rectangle(box, radius=10, outline=GREEN, width=5)
im.crop((400, 615, 1900, 1520)).save(dst, optimize=True)
print('wrote', dst, im.size)
