"""AIFlow Math Ink 0.5의 JSON-like stroke 입력 예시.""" from pathlib import Path from PIL import Image from aiflow_math_ink_05 import ( build_formula_grids, parse_writing_events, render_grid_images, ) def main() -> None: """필요 변수: 예제 stroke payload. 작동 원리: 수식 셀을 만들고 UTF-8 경로 아래 PNG로 저장한다.""" events = [ { "stroke_id": 0, "width": 3, "points": [{"x": 24, "y": 20}, {"x": 36, "y": 20}], }, { "stroke_id": 1, "width": 3, "points": [{"x": 10, "y": 42}, {"x": 60, "y": 42}], }, { "stroke_id": 2, "width": 3, "points": [{"x": 24, "y": 64}, {"x": 36, "y": 64}], }, ] strokes = parse_writing_events(events) grids = build_formula_grids(strokes) images = render_grid_images(Image.new("RGB", (80, 90), "white"), strokes, grids) output_directory = Path("outputs") output_directory.mkdir(exist_ok=True) for grid, image in zip(grids, images, strict=True): image.save(output_directory / f"cell-{grid.index}.png") if __name__ == "__main__": main()