import asyncio
from playwright.async_api import async_playwright

async def render(html_file, output_file):
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page(viewport={"width": 2816, "height": 1536}, device_scale_factor=1)
        await page.goto(f"file:///root/.openclaw/workspace/phat-deck-images/{html_file}", wait_until="networkidle")
        await page.wait_for_timeout(2000)  # let fonts load
        await page.screenshot(path=f"/root/.openclaw/workspace/phat-deck-images/{output_file}", full_page=False)
        await browser.close()
        print(f"Rendered {output_file}")

async def main():
    for i in range(1, 4):
        await render(f"v{i}.html", f"slide13_diagram_v{i}.png")

asyncio.run(main())
