cwLeeDev's picture
Release AIFlow Math Ink 0.5 geometric gridding layer
b9c7f6c verified
Raw
History Blame Contribute Delete
1.21 kB
"""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()