Release NaraMotion v0.26.0: Structure of Arrays (SoA), Path Arena Allocator, Uniform Grid Indexing, Dual-Buffer Rendering & Centroid Spring Pop-in
b516e00 verified Download tests/test_path.py from ArifiIslam/NaraMotion: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/ArifiIslam/NaraMotion/resolve/main/tests/test_path.py
- Command line
-
hf download hf://ArifiIslam/NaraMotion/tests/test_path.py
-
curl -L -o test_path.py https://huggingface.co/ArifiIslam/NaraMotion/resolve/main/tests/test_path.py
1.37 kB
| import pytest | |
| from naramotion import Path, Matrix2D, FillRule, Image, Context, Format | |
| def test_path_basic_verbs(): | |
| p = Path() | |
| assert p.is_empty() | |
| p.move_to(0, 0) | |
| p.line_to(100, 0) | |
| p.line_to(100, 100) | |
| p.close() | |
| assert not p.is_empty() | |
| assert p.size > 0 | |
| bounds = p.get_bounds() | |
| assert bounds.x0 == 0.0 | |
| assert bounds.y0 == 0.0 | |
| assert bounds.x1 == 100.0 | |
| assert bounds.y1 == 100.0 | |
| def test_path_hit_test(): | |
| p = Path() | |
| p.add_rect(10, 10, 80, 80) | |
| assert p.hit_test(50, 50, FillRule.NON_ZERO) is True | |
| assert p.hit_test(5, 5, FillRule.NON_ZERO) is False | |
| assert p.hit_test(150, 150, FillRule.NON_ZERO) is False | |
| def test_path_transform(): | |
| p = Path() | |
| p.add_rect(0, 0, 50, 50) | |
| m = Matrix2D.make_translation(100, 200) | |
| p.transform(m) | |
| bounds = p.get_bounds() | |
| assert bounds.x0 == 100.0 | |
| assert bounds.y0 == 200.0 | |
| assert bounds.x1 == 150.0 | |
| assert bounds.y1 == 250.0 | |
| def test_path_render(): | |
| img = Image(300, 300, Format.PRGB32) | |
| with Context(img) as ctx: | |
| p = Path() | |
| p.move_to(50, 50) | |
| p.cubic_to(100, 0, 200, 150, 250, 50) | |
| p.quad_to(200, 250, 50, 50) | |
| p.close() | |
| ctx.fill_path(p, "coral") | |
| ctx.stroke_width = 4.0 | |
| ctx.stroke_path(p, "navy") | |